pytmtc is a package now
This commit is contained in:
20
pytmtc/tests/test_serde.py
Normal file
20
pytmtc/tests/test_serde.py
Normal file
@ -0,0 +1,20 @@
|
||||
import struct
|
||||
from opssat_tmtc.camera_params import CameraParameters
|
||||
from opssat_tmtc.common import make_unique_id, EXPERIMENT_APID
|
||||
|
||||
|
||||
def test_serde_serialization():
|
||||
# Example serializatn
|
||||
data = bytearray(make_unique_id(EXPERIMENT_APID))
|
||||
params = CameraParameters(8, 8, 8, 1, True, 200, 1000)
|
||||
serialized = params.to_json().encode("utf-8")
|
||||
byte_string = bytearray(struct.pack("!{}s".format(len(serialized)), serialized))
|
||||
print(byte_string)
|
||||
print(params.serialize_for_uplink())
|
||||
data.extend(params.serialize_for_uplink())
|
||||
print(data)
|
||||
|
||||
# Example deserialization
|
||||
data = '{"R": 100, "G": 150, "B": 200, "N": 3, "P": true, "E": 10, "W": 20}'
|
||||
deserialized_params = CameraParameters.from_json(data)
|
||||
print(deserialized_params)
|
Reference in New Issue
Block a user