diff --git a/python/filereceiver/__init__.py b/python/filereceiver/__init__.py index 43ebc79a..935caf7d 100644 --- a/python/filereceiver/__init__.py +++ b/python/filereceiver/__init__.py @@ -20,5 +20,6 @@ from .k2sat import k2sat from .lucky7 import lucky7 from .sat_1kuns_pf import sat_1kuns_pf +from .smogp import smog1 from .smogp import smogp from .swiatowid import swiatowid diff --git a/python/filereceiver/smogp.py b/python/filereceiver/smogp.py index 4d333485..5b42e637 100644 --- a/python/filereceiver/smogp.py +++ b/python/filereceiver/smogp.py @@ -11,9 +11,10 @@ from construct.core import ConstructError from .filereceiver import FileReceiver -from ..telemetry import smogp as tlm +from ..telemetry import smogp as tlm_smogp +from ..telemetry import smog1 as tlm_smog1 -class FileReceiverSMOGP(FileReceiver): +class FileReceiverSMOG(FileReceiver): def file_id(self, chunk): return f'spectrum_start_{chunk.startfreq}_step_{chunk.stepfreq}_rbw_{chunk.rbw}_measid_{chunk.measid}' @@ -31,9 +32,16 @@ def file_size(self, chunk): def parse_chunk(self, chunk): try: - frame = tlm.parse(chunk) + frame = self._tlm.parse(chunk) except ConstructError: return None return frame.payload if frame.type == 5 else None +class FileReceiverSMOGP(FileReceiverSMOG): + _tlm = tlm_smogp + +class FileReceiverSMOG1(FileReceiverSMOG): + _tlm = tlm_smog1 + smogp = FileReceiverSMOGP +smog1 = FileReceiverSMOG1 diff --git a/python/satyaml/SMOG-1.yml b/python/satyaml/SMOG-1.yml index 9f4c0bd1..418949c0 100644 --- a/python/satyaml/SMOG-1.yml +++ b/python/satyaml/SMOG-1.yml @@ -4,11 +4,11 @@ telemetry_servers: - BME data: &tlm Telemetry: - telemetry: smogp + telemetry: smog1 &signalling Signalling: telemetry: smogp_signalling &spectrum Spectrum: - files: smogp + files: smog1 transmitters: 1k25 FSK long concatenated FEC: frequency: 437.345e+6 diff --git a/python/telemetry/__init__.py b/python/telemetry/__init__.py index 18b1d09e..70caa851 100644 --- a/python/telemetry/__init__.py +++ b/python/telemetry/__init__.py @@ -44,6 +44,7 @@ from .sat_1kuns_pf import sat_1kuns_pf from .sat_3cat_1 import sat_3cat_1 from .sat_3cat_2 import sat_3cat_2 +from .smogp import smog1 from .smogp import smogp from .smogp import smogp_signalling from .snet import snet diff --git a/python/telemetry/smogp.py b/python/telemetry/smogp.py index f5a5aab7..729e7717 100644 --- a/python/telemetry/smogp.py +++ b/python/telemetry/smogp.py @@ -123,6 +123,17 @@ 'ack_info' / AckInfo[3] ) +# This is like SMOG-P but with some extra fields at the end +Telemetry2_SMOG1 = Struct( + 'timestamp' / Timestamp, + 'pcu_dep' / PCU_DEP[2], + 'pcu_sdc' / PCU_SDC[2], + 'pcu_bat' / PCU_Bat[2], # Note ATL-1 doesn't use pcu_bat, but leaves these bytes unused + 'pcu_bus' / PCU_Bus[2], + 'ack_info' / AckInfo[3], + 'pcu_voltage' / Voltage[2] + ) + ComStatus = BitStruct( 'com_data_rate' / BitsInteger(3), 'tx_power_level' / BitsInteger(2), @@ -147,6 +158,14 @@ 'current_com' / BitsInteger(1) ) +Functional_SMOG1 = BitStruct( + 'msen' / Flag[2], + 'flash' / Flag[2], + 'rtcc' / Flag[2], + 'obc' / BitsInteger(1), # active OBC + 'current_com' / BitsInteger(1) # active COM + ) + COM = Struct( 'timestamp' / Timestamp, 'swr_bridge' / Int8ul, @@ -172,6 +191,13 @@ 'msen_temperature' / Temperature ) +MSEN_SMOG1 = Struct( + 'msen_gyroscope' / Int16sl[3], + 'msen_magneto' / Int16sl[3], + 'msen_accel' / Int16sl[3], + 'msen_temperature' / Temperature + ) + Telemetry3 = Struct( 'timestamp' / Timestamp, 'obc_supply_voltage' / Voltage, @@ -189,6 +215,24 @@ 'ack_info' / AckInfo[3] ) +# This is like SMOG-P but with an some fields instead of padding +Telemetry3_SMOG1 = Struct( + 'timestamp' / Timestamp, + 'obc_supply_voltage' / Voltage, + 'rtcc_temperature' / Temperature[2], + 'obc_temperature' / Temperature, + 'eps2_panel_a_temperature' / Temperature[2], + 'com_status' / ComStatus, + 'com_tx_current' / Int16ul, + 'com_rx_current' / Int16ul, + 'com_protection' / ComProtection, + 'msen' / MSEN_SMOG1[2], + 'functional' / Functional_SMOG1, + 'com' / COM, + 'tid' / TID[2], + 'ack_info' / AckInfo[3] + ) + UplinkStats = Struct( 'valid_packets' / Int32sl, 'rx_error_wrong_size' / Int16ul, @@ -203,7 +247,38 @@ 'beacon_message' / PaddedString(80, 'utf8'), 'uplink_stats' / UplinkStats, 'ack_info' / AckInfo[3] - ) + ) + +DiagnosticStatus = BitStruct( + 'energy_mode' / BitsInteger(3), + 'tcxo_works' / Flag, + 'filesystem_works' / Flag, + 'filesystem_uses_flash2' / Flag, + Padding(2) + ) + +DiagnosticInfo = Struct( + Padding(1), + 'num_recv_pkt_garbage' / Int8ul, + 'num_recv_pkt_bad_serial' / Int8ul, + 'num_recv_pkt_invalid' / Int8ul, + 'last_uplink_timestamp' / Timestamp, + 'obc_uptime_min' / Int24ub, + 'com_uptime_min' / Int24ub, + 'tx_voltage_drop_10mv' / Int8ul, + 'timed_task_count' / Int8ul, + 'status' / DiagnosticStatus + ) + +# This includes notable changes with repect to SMOG-P +# uplink_stats is replaced by diagnostic_stats and version +Beacon_SMOG1 = Struct( + 'timestamp' / Timestamp, + 'beacon_message' / PaddedString(80, 'utf8'), + 'diagnostic_stats' / DiagnosticInfo, + 'version' / PaddedString(7, 'utf8'), + 'ack_info' / AckInfo[3] + ) SpectrumResult = Struct( 'timestamp' / Timestamp, @@ -218,6 +293,21 @@ 'spectrum_data' / Bytes(this.spectrum_len) ) +# This adds the field request_uplink_serial +# in comparison to SMOG-P +SpectrumResult_SMOG1 = Struct( + 'timestamp' / Timestamp, + 'startfreq' / Int32ul, + 'stepfreq' / Int32ul, + 'rbw' / Int8ul, + 'pckt_index' / Int8ul, + 'pckt_count' / Int8ul, + 'spectrum_len' / Int16ul, + 'request_uplink_serial' / Int16ul, + 'measid' / Int16ul, + 'spectrum_data' / Bytes(this.spectrum_len) + ) + File = Struct( 'file_id' / Int8ul, 'file_type' / Int8ul, @@ -396,6 +486,18 @@ }, default = GreedyBytes) ) +smog1 = Struct( + 'type' / Int8ul, + 'payload' / Switch(this.type, { + 1 : Telemetry1, + 2 : Telemetry2_SMOG1, + 3 : Telemetry3_SMOG1, + 4 : Beacon_SMOG1, + 5 : SpectrumResult_SMOG1, + 7 : FileFragment, + }, default = GreedyBytes) + ) + signalling_prbs = np.array([0x97, 0xfd, 0xd3, 0x7b, 0x0f, 0x1f, 0x6d,\ 0x08, 0xf7, 0x83, 0x5d, 0x9e, 0x59, 0x82,\ 0xc0, 0xfd, 0x1d, 0xca, 0xad, 0x3b, 0x5b,\