Skip to content

Commit

Permalink
Update SMOG-P telemetry parser to support SMOG-1
Browse files Browse the repository at this point in the history
(cherry picked from commit c111636)
  • Loading branch information
daniestevez committed Mar 20, 2021
1 parent 1ac3e9e commit 011d01d
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 6 deletions.
1 change: 1 addition & 0 deletions python/filereceiver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 11 additions & 3 deletions python/filereceiver/smogp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'

Expand All @@ -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
4 changes: 2 additions & 2 deletions python/satyaml/SMOG-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions python/telemetry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
104 changes: 103 additions & 1 deletion python/telemetry/smogp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,\
Expand Down

0 comments on commit 011d01d

Please sign in to comment.