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