mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 10:04:33 +02:00
added crc check and sleeping time for processing bigger data
This commit is contained in:
parent
4cce8aec5c
commit
2ba8b77ea7
|
@ -13,6 +13,7 @@ import base64
|
||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
import time
|
import time
|
||||||
|
import crcengine
|
||||||
|
|
||||||
# --------------------------------------------GET PARAMETER INPUTS
|
# --------------------------------------------GET PARAMETER INPUTS
|
||||||
parser = argparse.ArgumentParser(description='Simons TEST TNC')
|
parser = argparse.ArgumentParser(description='Simons TEST TNC')
|
||||||
|
@ -64,9 +65,15 @@ msg_with_attachment = chatmessage + \
|
||||||
split_char + \
|
split_char + \
|
||||||
timestamp
|
timestamp
|
||||||
|
|
||||||
|
# calculate checksum
|
||||||
|
crc_algorithm = crcengine.new("crc32") # load crc32 library
|
||||||
|
crc_data = crc_algorithm(file)
|
||||||
|
crc_data = crc_data.to_bytes(4, byteorder="big")
|
||||||
|
|
||||||
|
|
||||||
datatype = b"m"
|
datatype = b"m"
|
||||||
command = b"send_message"
|
command = b"send_message"
|
||||||
checksum = b"123"
|
checksum = bytes(crc_data.hex(), "utf-8")
|
||||||
uuid_4 = bytes(str(uuid.uuid4()), "utf-8")
|
uuid_4 = bytes(str(uuid.uuid4()), "utf-8")
|
||||||
|
|
||||||
data = datatype + \
|
data = datatype + \
|
||||||
|
@ -98,9 +105,13 @@ command = {"type": "arq",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
command = json.dumps(command)
|
command = json.dumps(command)
|
||||||
|
print(command)
|
||||||
command = bytes(command + "\n", 'utf-8')
|
command = bytes(command + "\n", 'utf-8')
|
||||||
# Create a socket (SOCK_STREAM means a TCP socket)
|
# Create a socket (SOCK_STREAM means a TCP socket)
|
||||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
||||||
# Connect to server and send data
|
# Connect to server and send data
|
||||||
sock.connect((HOST, PORT))
|
sock.connect((HOST, PORT))
|
||||||
sock.sendall(command)
|
sock.sendall(command)
|
||||||
|
timeout = time.time() + 5
|
||||||
|
while time.time() < timeout:
|
||||||
|
pass
|
Loading…
Reference in a new issue