updated data frame

This commit is contained in:
DJ2LS 2021-08-15 18:15:08 +02:00 committed by GitHub
parent 32bba9845f
commit 041dee89c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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]))