mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
select serial speed
This commit is contained in:
parent
40b2d53bc5
commit
2ec1f7ead7
|
@ -112,11 +112,12 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
tx_audio = received_json["parameter"][0]["tx_audio"]
|
||||
deviceid = received_json["parameter"][0]["deviceid"]
|
||||
deviceport = received_json["parameter"][0]["deviceport"]
|
||||
serialspeed = received_json["parameter"][0]["serialspeed"]
|
||||
ptt = received_json["parameter"][0]["ptt"]
|
||||
print("STARTING TNC !!!!!")
|
||||
print(received_json["parameter"][0])
|
||||
#os.system("python3 main.py --rx 3 --tx 3 --deviceport /dev/ttyUSB0 --deviceid 2028")
|
||||
p = subprocess.Popen("exec python3 main.py --rx "+ str(rx_audio) +" --tx "+ str(tx_audio) +" --deviceport "+ str(deviceport) +" --deviceid "+ str(deviceid) + " --ptt "+ str(ptt), shell=True)
|
||||
p = subprocess.Popen("exec python3 main.py --rx "+ str(rx_audio) +" --tx "+ str(tx_audio) +" --deviceport "+ str(deviceport) +" --deviceid "+ str(deviceid) + " --serialspeed "+ str(serialspeed) + " --ptt "+ str(ptt), shell=True)
|
||||
static.TNCPROCESS = p#.pid
|
||||
#print(parameter)
|
||||
# print(static.TNCPROCESS)
|
||||
|
|
|
@ -24,6 +24,7 @@ if __name__ == '__main__':
|
|||
PARSER.add_argument('--port', dest="socket_port", default=3000, help="Socket port", type=int)
|
||||
PARSER.add_argument('--deviceport', dest="hamlib_device_port", default="/dev/ttyUSB0", help="Socket port", type=str)
|
||||
PARSER.add_argument('--deviceid', dest="hamlib_device_id", default=3011, help="Socket port", type=int)
|
||||
PARSER.add_argument('--serialspeed', dest="hamlib_serialspeed", default=9600, help="Serialspeed", type=str)
|
||||
PARSER.add_argument('--ptt', dest="hamlib_ptt_type", default='RTS', help="PTT Type", type=str)
|
||||
|
||||
|
||||
|
@ -35,7 +36,7 @@ if __name__ == '__main__':
|
|||
static.HAMLIB_DEVICE_ID = ARGS.hamlib_device_id
|
||||
static.HAMLIB_DEVICE_PORT = ARGS.hamlib_device_port
|
||||
static.HAMLIB_PTT_TYPE = ARGS.hamlib_ptt_type
|
||||
|
||||
static.HAMLIB_SERIAL_SPEED = ARGS.hamlib_serialspeed
|
||||
|
||||
# we need to wait until we got all parameters from argparse first before we can load the other modules
|
||||
import sock
|
||||
|
|
|
@ -86,7 +86,7 @@ class RF():
|
|||
self.my_rig.set_conf("rig_pathname", static.HAMLIB_DEVICE_PORT)
|
||||
|
||||
self.my_rig.set_conf("retry", "5")
|
||||
self.my_rig.set_conf("serial_speed", "9600")
|
||||
self.my_rig.set_conf("serial_speed", static.HAMLIB_SERIAL_SPEED)
|
||||
|
||||
#self.my_rig.set_conf("dtr_state", "OFF")
|
||||
#my_rig.set_conf("rts_state", "OFF")
|
||||
|
|
36
tnc/sock.py
36
tnc/sock.py
|
@ -17,6 +17,7 @@ import static
|
|||
import data_handler
|
||||
import helpers
|
||||
|
||||
import sys, os
|
||||
|
||||
class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||
|
||||
|
@ -50,7 +51,7 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
|
||||
try:
|
||||
received_json = json.loads(data)
|
||||
print(received_json)
|
||||
#print(received_json)
|
||||
except:
|
||||
received_json = ''
|
||||
|
||||
|
@ -73,10 +74,10 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
try:
|
||||
# SOCKETTEST ---------------------------------------------------
|
||||
#if data == 'SOCKETTEST':
|
||||
if received_json["command"] == "SOCKETTEST":
|
||||
#cur_thread = threading.current_thread()
|
||||
response = bytes("WELL DONE! YOU ARE ABLE TO COMMUNICATE WITH THE TNC", encoding)
|
||||
self.request.sendall(response)
|
||||
#if received_json["command"] == "SOCKETTEST":
|
||||
# #cur_thread = threading.current_thread()
|
||||
# response = bytes("WELL DONE! YOU ARE ABLE TO COMMUNICATE WITH THE TNC", encoding)
|
||||
# self.request.sendall(response)
|
||||
|
||||
# CQ CQ CQ -----------------------------------------------------
|
||||
#if data == 'CQCQCQ':
|
||||
|
@ -198,11 +199,20 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
"FREQUENCY" : str(static.HAMLIB_FREQUENCY),
|
||||
"MODE" : str(static.HAMLIB_MODE),
|
||||
"BANDWITH" : str(static.HAMLIB_BANDWITH),
|
||||
"FFT" : str(static.FFT)
|
||||
"FFT" : str(static.FFT),
|
||||
#"RX_BUFFER_LENGTH": str(len(static.RX_BUFFER)),
|
||||
#"TX_N_MAX_RETRIES": str(static.TX_N_MAX_RETRIES),
|
||||
#"ARQ_TX_N_FRAMES_PER_BURST": str(static.ARQ_TX_N_FRAMES_PER_BURST),
|
||||
#"ARQ_TX_N_BURSTS": str(static.ARQ_TX_N_BURSTS),
|
||||
#"ARQ_TX_N_CURRENT_ARQ_FRAME": str(int.from_bytes(bytes(static.ARQ_TX_N_CURRENT_ARQ_FRAME), "big")),
|
||||
#"ARQ_TX_N_TOTAL_ARQ_FRAMES": str(int.from_bytes(bytes(static.ARQ_TX_N_TOTAL_ARQ_FRAMES), "big")),
|
||||
#"ARQ_RX_FRAME_N_BURSTS": str(static.ARQ_RX_FRAME_N_BURSTS),
|
||||
#"ARQ_RX_N_CURRENT_ARQ_FRAME": str(static.ARQ_RX_N_CURRENT_ARQ_FRAME),
|
||||
#"ARQ_N_ARQ_FRAMES_PER_DATA_FRAME": str(static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME)
|
||||
}
|
||||
|
||||
jsondata = json.dumps(output)
|
||||
print(len(jsondata))
|
||||
#print(len(jsondata))
|
||||
self.request.sendall(bytes(jsondata, encoding))
|
||||
|
||||
if received_json["type"] == 'GET' and received_json["command"] == 'FFT':
|
||||
|
@ -230,12 +240,14 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
jsondata = json.dumps(output)
|
||||
self.request.sendall(bytes(jsondata, encoding))
|
||||
|
||||
print(static.HEARD_STATIONS)
|
||||
if received_json["type"] == 'GET' and received_json["command"] == 'HEARD_STATIONS':
|
||||
print("HEARD STATIONS COMMAND!")
|
||||
output = []
|
||||
for i in range(0, len(static.HEARD_STATIONS)):
|
||||
output.append({"COMMAND": "HEARD_STATIONS", "DXCALLSIGN": str(static.HEARD_STATIONS[i][0], 'utf-8'),"DXGRID": str(static.HEARD_STATIONS[i][1], 'utf-8'), "TIMESTAMP": static.HEARD_STATIONS[i][2], "DATATYPE": static.HEARD_STATIONS[i][3]})
|
||||
|
||||
jsondata = json.dumps(output)
|
||||
jsondata = json.loads(output)
|
||||
self.request.sendall(bytes(jsondata, encoding))
|
||||
|
||||
|
||||
|
@ -253,8 +265,12 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
static.RX_BUFFER = []
|
||||
|
||||
#exception, if JSON cant be decoded
|
||||
except:
|
||||
print("Wrong command")
|
||||
except Exception as e:
|
||||
#print("Wrong command: " + data)
|
||||
#print(e)
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||
print(exc_type, fname, exc_tb.tb_lineno)
|
||||
print("Client disconnected...")
|
||||
|
||||
def start_cmd_socket():
|
||||
|
|
|
@ -61,6 +61,8 @@ PTT_STATE = False
|
|||
|
||||
HAMLIB_DEVICE_ID = 0
|
||||
HAMLIB_DEVICE_PORT = '/dev/ttyUSB0'
|
||||
HAMLIB_SERIAL_SPEED = '9600'
|
||||
|
||||
|
||||
HAMLIB_FREQUENCY = 0
|
||||
HAMLIB_MODE = ''
|
||||
|
|
Loading…
Reference in a new issue