mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
updated data frame
This commit is contained in:
parent
32bba9845f
commit
041dee89c7
1 changed files with 35 additions and 10 deletions
45
tnc/sock.py
45
tnc/sock.py
|
@ -122,7 +122,8 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
static.DXCALLSIGN = bytes(dxcallsign, 'utf-8')
|
||||
static.DXCALLSIGN_CRC8 = helpers.get_crc_8(static.DXCALLSIGN)
|
||||
|
||||
dataframe = '{"filename": "'+ filename + '", "filetype" : "' + filetype + '", "data" : "' + data + '", "checksum" : "' + checksum + '"}'
|
||||
#dataframe = '{"filename": "'+ filename + '", "filetype" : "' + filetype + '", "data" : "' + data + '", "checksum" : "' + checksum + '"}'
|
||||
dataframe = {"filename" : filename , "filetype" :filetype, "data" : data, "checksum" :checksum}
|
||||
#data_out = bytes(received_json["data"], 'utf-8')
|
||||
data_out = bytes(dataframe, 'utf-8')
|
||||
|
||||
|
@ -213,17 +214,41 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
|
||||
|
||||
if received_json["type"] == 'GET' and received_json["command"] == 'RX_BUFFER':
|
||||
output = {
|
||||
"COMMAND": "RX_BUFFER",
|
||||
"DATA" : [],
|
||||
"EOF" : "EOF",
|
||||
}
|
||||
for i in range(0, len(static.RX_BUFFER)):
|
||||
#print(static.RX_BUFFER[i])
|
||||
|
||||
|
||||
output["DATA"].append({"DXCALLSIGN": str(static.RX_BUFFER[i][0], 'utf-8'),"DXGRID": str(static.RX_BUFFER[i][1], 'utf-8'), "TIMESTAMP": static.RX_BUFFER[i][2], "DATA": static.RX_BUFFER[i][3]})
|
||||
|
||||
print(output)
|
||||
jsondata = json.dumps(output)
|
||||
|
||||
print(jsondata)
|
||||
self.request.sendall(bytes(jsondata, encoding))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#data = data.split('GET:RX_BUFFER:')
|
||||
#bufferposition = int(data[1]) - 1
|
||||
print("BUFFER-LENGTH:" + str(len(static.RX_BUFFER)))
|
||||
bufferposition = 1
|
||||
if bufferposition == -1:
|
||||
if len(static.RX_BUFFER) > 0:
|
||||
self.request.sendall(static.RX_BUFFER[-1])
|
||||
|
||||
if bufferposition <= len(static.RX_BUFFER) > 0:
|
||||
print(static.RX_BUFFER[bufferposition])
|
||||
self.request.sendall(bytes(static.RX_BUFFER[bufferposition]))
|
||||
# print("BUFFER-LENGTH:" + str(len(static.RX_BUFFER)))
|
||||
# bufferposition = 1
|
||||
# if bufferposition == -1:
|
||||
# if len(static.RX_BUFFER) > 0:
|
||||
# self.request.sendall(static.RX_BUFFER[-1])
|
||||
#if bufferposition <= len(static.RX_BUFFER) > 0:
|
||||
# print(static.RX_BUFFER[bufferposition])
|
||||
# self.request.sendall(bytes(static.RX_BUFFER[bufferposition]))
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue