Improvements to Loop Mode and HK Parsing #73
@ -5,7 +5,7 @@ import base64
|
||||
|
||||
from tmtccmd.logging import get_console_logger
|
||||
from tmtccmd.utility.obj_id import ObjectId
|
||||
|
||||
from dle_encoder import DleEncoder
|
||||
|
||||
# TODO add to configuration parameters
|
||||
SERVER_HOST = ""
|
||||
@ -32,6 +32,8 @@ class TmTcpServer:
|
||||
|
||||
self.client_connection: Optional[socket.socket] = None
|
||||
|
||||
self.dle_encoder = DleEncoder()
|
||||
|
||||
def __del__(self):
|
||||
try:
|
||||
self.close()
|
||||
@ -62,11 +64,8 @@ class TmTcpServer:
|
||||
data_json_bytes = json.dumps(dictionary).encode()
|
||||
|
||||
# dle encode the bytes
|
||||
# Taking a shortcut as json is inherently
|
||||
# not binary (we also encoded it as utf-8), so there
|
||||
# can not be any 0x02 or 0x03 be in there
|
||||
# TODO use dle encoder to be format compliant
|
||||
data_json_bytes = b'\x02' + data_json_bytes + b'\n' + b'\x03'
|
||||
# adding a newline because someone might want to look at it in a console
|
||||
data_json_bytes = self.dle_encoder.encode(data_json_bytes + b'\n')
|
||||
|
||||
try:
|
||||
sent_length = self.client_connection.send(data_json_bytes)
|
||||
|
Loading…
x
Reference in New Issue
Block a user