Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gioyik committed Aug 8, 2023
1 parent e26a62c commit bd1caa3
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 76 deletions.
2 changes: 1 addition & 1 deletion python/satyaml/S-NET_A.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: S-NET A
norad: 43188
norad: 43186
alternative_names:
- DP0TBB
data:
Expand Down
2 changes: 1 addition & 1 deletion python/satyaml/S-NET_C.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: S-NET C
norad: 43189
norad: 43188
alternative_names:
- DP0TBD
data:
Expand Down
2 changes: 1 addition & 1 deletion python/satyaml/S-NET_D.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: S-NET D
norad: 43186
norad: 43189
alternative_names:
- DP0TBE
data:
Expand Down
7 changes: 1 addition & 6 deletions python/snet_deframer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
from gnuradio import gr
import numpy as np
import pmt
from construct import *

from .bch15 import decode_bch15
from .telemetry.snet import LTUFrameHeader, PDUFrameHeader
from .telemetry.snet import LTUFrameHeader


class snet_deframer(gr.basic_block):
Expand Down Expand Up @@ -167,10 +166,6 @@ def handle_msg(self, msg_pmt):

pdu = np.packbits(pdu_bytes)

if self.verbose:
pdu_parsed = PDUFrameHeader.parse(pdu)
print(pdu_parsed)

pdu_tags = pmt.make_dict()
pdu_tags = pmt.dict_add(
pdu_tags, pmt.intern('SNET SrcId'), pmt.from_long(hdr.SrcId))
Expand Down
151 changes: 84 additions & 67 deletions python/telemetry/snet.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,71 @@
# QldqXP-TUBIX10_3800_TN03_TM_Frame_01.pdf
# for documentation

LTUFrameHeader = BitStruct(
'SrcId' / BitsInteger(7),
'DstId' / BitsInteger(7),
'FrCntTx' / BitsInteger(4),
'FrCntRx' / BitsInteger(4),
'SNR' / BitsInteger(4),
'AiTypeSrc' / BitsInteger(4),
'AiTypeDst' / BitsInteger(4),
'DfcId' / BitsInteger(2),
'Caller' / Flag,
'Arq' / Flag,
'PduTypeId' / Flag,
'BchRq' / Flag,
'Hailing' / Flag,
'UdFl1' / Flag,
'PduLength' / BitsInteger(10),
'CRC13' / BitsInteger(13),
'CRC5' / BitsInteger(5),
Padding(2)
)


class TimeAdapter(Adapter):
def _encode(self, obj, context, path=None):
d = int((obj - datetime.datetime(2000, 1, 1))*2)
return Container(
days=d.days,
milliseconds=d.seconds * 1000 + d.microseconds / 1000)

def _decode(self, obj, context, path=None):
return (datetime.datetime(2000, 1, 1)
+ datetime.timedelta(seconds=float(obj)/2.0))


TimeStamp = TimeAdapter(BitsInteger(32, swapped=True))

PDUFrameHeaderExtension = BitStruct(
'VersNo' / BitsInteger(2),
'DFCID' / BitsInteger(2),
'ExtensionRFU' / BitsInteger(4),
'ChannelInfo' / BitsInteger(8),
'QoS' / Flag,
'PDUTypeID' / Flag,
'ARQ' / Flag,
'ControlRFU' / BitsInteger(5),
'TimeTagSub' / BitsInteger(16),
'SCID' / BitsInteger(10),
'SeqNo' / BitsInteger(14)
)

PDUFrameHeader = BitStruct(
Const(0b111100110101000000, BitsInteger(18)),
'CRC' / BitsInteger(14),
'FCIDMajor' / BitsInteger(6),
'FCIDSub' / BitsInteger(10),
'Urgent' / Flag,
'Extended' / Flag,
'CheckCRC' / Flag,
'Multiframe' / Flag,
'TimeTaggedSetting' / Flag,
'TimeTagged' / Flag,
'DataLength' / BitsInteger(10),
'TimeTag' / If(lambda c: c.TimeTagged, TimeStamp),
'Extension' / If(lambda c: c.Extended, PDUFrameHeaderExtension))

Battery = Struct(
'V_BAT' / LinearAdapter(2, Int16sl),
'A_IN_CHARGER' / LinearAdapter(12, Int16sl),
Expand Down Expand Up @@ -102,27 +167,6 @@
'TargetData_ControlIsActive' / Int8ul # flag, really
)

LTUFrameHeader = BitStruct(
'SrcId' / BitsInteger(7),
'DstId' / BitsInteger(7),
'FrCntTx' / BitsInteger(4),
'FrCntRx' / BitsInteger(4),
'SNR' / BitsInteger(4),
'AiTypeSrc' / BitsInteger(4),
'AiTypeDst' / BitsInteger(4),
'DfcId' / BitsInteger(2),
'Caller' / Flag,
'Arq' / Flag,
'PduTypeId' / Flag,
'BchRq' / Flag,
'Hailing' / Flag,
'UdFl1' / Flag,
'PduLength' / BitsInteger(10),
'CRC13' / BitsInteger(13),
'CRC5' / BitsInteger(5),
Padding(2)
)

# Mailbox in SNET satellites
# There are three main fields defining the Mailbox inside SNET satellites:
#
Expand All @@ -137,60 +181,33 @@
# * `MemData32` is an Array of bytes, where each byte corresponds to an ascii
# character code. The transmission of words is done by Big-Endian order.


class MemData32Adapter(Adapter):
def _encode(self, obj, context, path=None):
return bytes([x << 1 for x in bytes(
(obj.upper() + ' '*8)[:8], encoding='ascii')])

def _decode(self, obj, context, path=None):
# do we need to do right shift here?
return str(bytes([x for x in bytes(
(obj.upper() + ' '*8)[:8], encoding='ascii')]),
encoding='ascii').strip()


MemData32 = MemData32Adapter(BitsInteger(256))

MailboxReceiveTelemetry = Struct(
'SysTime' / BitsInteger(32),
'MemDataType' / BitsInteger(8),
'MemData32' / BitsInteger(256)
'MemData32' / MemData32
)

MailboxSendTelemetry = Struct(
'MemDataType' / BitsInteger(8),
'MemData32' / BitsInteger(256)
)


class TimeAdapter(Adapter):
def _encode(self, obj, context, path=None):
d = int((obj - datetime.datetime(2000, 1, 1))*2)
return Container(
days=d.days,
milliseconds=d.seconds * 1000 + d.microseconds / 1000)

def _decode(self, obj, context, path=None):
return (datetime.datetime(2000, 1, 1)
+ datetime.timedelta(seconds=float(obj)/2.0))


TimeStamp = TimeAdapter(BitsInteger(32, swapped=True))

PDUFrameHeaderExtension = BitStruct(
'VersNo' / BitsInteger(2),
'DFCID' / BitsInteger(2),
'ExtensionRFU' / BitsInteger(4),
'ChannelInfo' / BitsInteger(8),
'QoS' / Flag,
'PDUTypeID' / Flag,
'ARQ' / Flag,
'ControlRFU' / BitsInteger(5),
'TimeTagSub' / BitsInteger(16),
'SCID' / BitsInteger(10),
'SeqNo' / BitsInteger(14)
)

PDUFrameHeader = BitStruct(
Const(0b111100110101000000, BitsInteger(18)),
'CRC' / BitsInteger(14),
'FCIDMajor' / BitsInteger(6),
'FCIDSub' / BitsInteger(10),
'Urgent' / Flag,
'Extended' / Flag,
'CheckCRC' / Flag,
'Multiframe' / Flag,
'TimeTaggedSetting' / Flag,
'TimeTagged' / Flag,
'DataLength' / BitsInteger(10),
'TimeTag' / If(lambda c: c.TimeTagged, TimeStamp),
'Extension' / If(lambda c: c.Extended, PDUFrameHeaderExtension),
Payload = BitStruct(
'UserData' / Switch(lambda c: (c.FCIDMajor, c.FCIDSub), {
(0, 0): ADCSTelemetry,
(9, 0): EPSTelemetry,
Expand All @@ -202,5 +219,5 @@ def _decode(self, obj, context, path=None):
default=Pass))

snet = Struct(
'header' / LTUFrameHeader,
'telemetry' / PDUFrameHeader)
'header' / PDUFrameHeader,
'data' / Payload)

0 comments on commit bd1caa3

Please sign in to comment.