48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
# Joint copyright of Josh Conway and discord user:winter_soldier#1984
|
|
# License is GPL3 (Gnu public license version 3)
|
|
|
|
|
|
import sys
|
|
import os
|
|
import time
|
|
import argparse
|
|
import base64
|
|
import socket
|
|
import zmq
|
|
import pmt
|
|
import random
|
|
import binascii
|
|
|
|
##### START PARSE COMMANDLINE INPUT #####
|
|
|
|
parser = argparse.ArgumentParser(description='Process incoming command parmeters')
|
|
parser.add_argument('-o', '--output', action='store', dest='output', help='SDR transmit of provided hex string. Does no processing of said data.')
|
|
parser.add_argument('-n', '--net', action='store',dest='net', help='Network TCP in ip or DNS. ZeroMQ protocol.')
|
|
parser.add_argument('-p', '--port', action='store',dest='port', help='Network port')
|
|
args = parser.parse_args()
|
|
|
|
##### END PARSE COMMANDLINE INPUT #####
|
|
|
|
##### START OPTIONAL NETWORK PROCESS #####
|
|
|
|
def networkTransmit(ipAddr, port, rawData):
|
|
context = zmq.Context()
|
|
socket = context.socket(zmq.PUSH)
|
|
socket.connect("tcp://" + ipAddr + ":" + port) # connect, not bind, the PUB will bind, only 1 can bind
|
|
print(f"Sending \"{rawData}\"")
|
|
data = binascii.hexlify(rawData.encode()).decode("utf-8")
|
|
socket.send(pmt.serialize_str(pmt.to_pmt(data)))
|
|
|
|
##### START OPTIONAL NETWORK PROCESS #####
|
|
|
|
if __name__ == "__main__":
|
|
|
|
# Network branch. Doesnt exit, so we need IP Port and data
|
|
try:
|
|
if len(args.net) > 0 and len(args.port) > 0:
|
|
print(args.net, args.port)
|
|
networkTransmit(args.net, args.port, args.output)
|
|
except Exception as e:
|
|
# No data, no workie
|
|
print("Transmission halted."+ str(e))
|