Skip to content

Commit

Permalink
Add support for SMOG-1
Browse files Browse the repository at this point in the history
This adds the following changes with respect to SMOG-P:
* Longer 48 bit syncword for the RA frames
  (the AO-40 frames also will have the longer syncword, but
   gr-satellites detects the distributed syncword)
* CRC-16 ARC checking for RA and AO-40 frames
* TX signalling frames

The telemetry parser is not done yet

(cherry picked from commit 1872e70)
  • Loading branch information
daniestevez committed Mar 20, 2021
1 parent feb02c1 commit 1ac3e9e
Show file tree
Hide file tree
Showing 13 changed files with 287 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support for SPUTNIX satellites: OrbiCraft-Zorkiy, CubeSX-HSE, CubeSX-Sirius-HSE, KSU CubeSat
- Support for TAUSAT-1 and TSURU
- 2k4 downlink for MEZNSAT
- Support for SMOG-1

### Fixed
- RS basis options swapped in CCSDS Reed-Solomon encoder GRC block
Expand Down
14 changes: 14 additions & 0 deletions docs/source/satyaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ The framings allowed in the ``framing`` field are the following:
* ``AO-40 FEC short``, AO-40 FEC protocol with short frames, as used by SMOG-P
and ATL-1

* ``AO-40 FEC CRC-16-ARC``, the AO-40 FEC protocol with an CRC-16 ARC, as used by
SMOG-1

* ``AO-40 FEC CRC-16-ARC short``, AO-40 FEC protocol with short frames and a
CRC-16 ARC, as used by SMOG-1

* ``CCSDS Reed-Solomon``, CCSDS Reed-Solomon TM codewords (see :ref:`CCSDS deframers`)

* ``CCSDS Concatenated``, CCSDS Concatenated TM codewords (see :ref:`CCSDS deframers`)
Expand Down Expand Up @@ -186,8 +192,16 @@ The framings allowed in the ``framing`` field are the following:

* ``SMOG-P RA``, Repeat-Accumulate FEC as used by SMOG-P and ATL-1

* ``SMOG-1 RA``, Repeat-Accumulate FEC as used by SMOG-1. The difference with
``SMOG-P RA`` is a longer 48 bit syncword (instead of 16 bit) and the inclusion
of a CRC-16 ARC to check frame integrity.

* ``SMOG-P Signalling``, custom signalling frames as used by SMOG-P and ATL-1

* ``SMOG-1 Signalling``, custom signalling frames as used by SMOG-1. The difference
with ``SMOG-P Signalling`` is the addition of a different PRBS to mark transitions
to TX mode.

* ``OPS-SAT``, custom framing used by OPS-SAT, which consists of AX.25 frames
with CCSDS Reed-Solomon codewords as payload

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ parameters:
dtype: bool
default: 'False'
options: ['True', 'False']
- id: crc
label: Use CRC-16 ARC
dtype: bool
default: 'False'
options: ['True', 'False']
- id: options
label: Command line options
dtype: string
Expand All @@ -28,7 +33,7 @@ outputs:

templates:
imports: import satellites.components.deframers
make: satellites.components.deframers.ao40_fec_deframer(syncword_threshold = ${threshold}, short_frames = ${short_frames}, options=${options})
make: satellites.components.deframers.ao40_fec_deframer(syncword_threshold = ${threshold}, short_frames = ${short_frames}, crc = ${crc}, options=${options})

documentation: |-
Deframes a signal using the AO-40 FEC protocol
Expand All @@ -42,6 +47,7 @@ documentation: |-
Parameters:
Syncword threshold: number of bit errors to allow in the detection of the 32 bit syncword
Use short frames (SMOG-P): enable usage of short frames, which is a variant employed by SMOG-P and ATL-1
Use CRC-16 ARC: use CRC-16 ARC (used in SMOG-1)
Command line options: options to pass down to the block, following the syntax of the gr_satellites command line tool
file_format: 1
11 changes: 9 additions & 2 deletions grc/components/deframers/satellites_smogp_ra_deframer.block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ parameters:
label: Syncword threshold
dtype: int
default: 0
- id: protocol
label: Protocol
dtype: enum
default: 'False'
options: ['False', 'True']
option_labels: ['SMOG-P', 'SMOG-1']
- id: options
label: Command line options
dtype: string
Expand All @@ -27,10 +33,10 @@ outputs:

templates:
imports: import satellites.components.deframers
make: satellites.components.deframers.smogp_ra_deframer(frame_size = ${frame_size}, syncword_threshold = ${threshold}, options=${options})
make: satellites.components.deframers.smogp_ra_deframer(frame_size = ${frame_size}, syncword_threshold = ${threshold}, new_protocol=${protocol}, options=${options})

documentation: |-
Deframes SMOG-P RA FEC frames
Deframes SMOG-P or SMOG-1 RA FEC frames
The frames use a Repeat-Accumulate FEC
Expand All @@ -43,6 +49,7 @@ documentation: |-
Parameters:
Frame size: size of the decode frame in bytes
Syncword threshold: number of bit errors to allow in syncword detection
Protocol: chooses between SMOG-P older protocol and SMOG-1 newer protocol
Command line options: options to pass down to the block, following the syntax of the gr_satellites command line tool
file_format: 1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ parameters:
label: Syncword threshold
dtype: int
default: 0
- id: protocol
label: Protocol
dtype: enum
default: 'False'
options: ['False', 'True']
option_labels: ['SMOG-P', 'SMOG-1']
- id: options
label: Command line options
dtype: string
Expand All @@ -23,10 +29,10 @@ outputs:

templates:
imports: import satellites.components.deframers
make: satellites.components.deframers.smogp_signalling_deframer(syncword_threshold = ${threshold}, options=${options})
make: satellites.components.deframers.smogp_signalling_deframer(syncword_threshold = ${threshold}, new_protocol=${protocol}, options=${options})

documentation: |-
Deframes SMOG-P signalling frames
Deframes SMOG-P or SMOG-1 signalling frames
Input:
A stream of soft symbols containing signalling frames
Expand All @@ -36,6 +42,7 @@ documentation: |-
Parameters:
Syncword threshold: number of bit errors to allow in syncword detection
Protocol: chooses between SMOG-P older protocol and SMOG-1 newer protocol
Command line options: options to pass down to the block, following the syntax of the gr_satellites command line tool
file_format: 1
13 changes: 9 additions & 4 deletions python/check_tt64_crc.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ class check_tt64_crc(gr.basic_block):
"""
docstring for block check_tt64_crc
"""
def __init__(self, verbose):
def __init__(self, verbose, packet_len = 48):
gr.basic_block.__init__(self,
name="check_tt64_crc",
in_sig=[],
out_sig=[])

self.verbose = verbose
self.packet_len = packet_len

self.message_port_register_in(pmt.intern('in'))
self.set_msg_handler(pmt.intern('in'), self.handle_msg)
Expand All @@ -81,14 +82,18 @@ def handle_msg(self, msg_pmt):
return
packet = bytes(pmt.u8vector_elements(msg))

if len(packet) < 48:
if self.packet_len is not None:
packet = packet[:self.packet_len]

if (self.packet_len is not None and len(packet) < self.packet_len) \
or (self.packet_len is None and len(packet) < 2):
if self.verbose:
print("Packet too short")
return

packet_out = packet[:46]
packet_out = packet[:-2]
msg_out = pmt.cons(pmt.PMT_NIL, pmt.init_u8vector(len(packet_out), packet_out))
if crc16_arc(packet[:48]) == 0:
if crc16_arc(packet) == 0:
if self.verbose:
print("CRC OK")
self.message_port_pub(pmt.intern('ok'), msg_out)
Expand Down
19 changes: 16 additions & 3 deletions python/components/deframers/ao40_fec_deframer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#

from gnuradio import gr, digital, fec, blocks
from ... import distributed_syncframe_soft, matrix_deinterleaver_soft, decode_rs
from ... import distributed_syncframe_soft, matrix_deinterleaver_soft, decode_rs,\
check_tt64_crc
from ...hier.ccsds_descrambler import ccsds_descrambler
from ...utils.options_block import options_block

Expand All @@ -26,9 +27,11 @@ class ao40_fec_deframer(gr.hier_block2, options_block):
Args:
syncword_threshold: number of bit errors allowed in syncword (int)
short_frames: use short frames (used in SMOG-P) (bool)
crc: use CRC-16 ARC (used in SMOG-P) (bool)
options: Options from argparse
"""
def __init__(self, syncword_threshold = None, short_frames = False, options = None):
def __init__(self, syncword_threshold = None, short_frames = False,
crc = False, options = None):
gr.hier_block2.__init__(self, "ao40_fec_deframer",
gr.io_signature(1, 1, gr.sizeof_float),
gr.io_signature(0, 0, 0))
Expand All @@ -49,12 +52,21 @@ def __init__(self, syncword_threshold = None, short_frames = False, options = No
self.scrambler = ccsds_descrambler()
self.rs = decode_rs(False, 1 if short_frames else 2)

if crc:
# CRC-16 ARC
self.crc = check_tt64_crc(verbose = self.options.verbose_crc,
packet_len = None)

self.connect(self, self.deframer)
self.msg_connect((self.deframer, 'out'), (self.deinterleaver, 'in'))
self.msg_connect((self.deinterleaver, 'out'), (self.viterbi_decoder, 'in'))
self.msg_connect((self.viterbi_decoder, 'out'), (self.scrambler, 'in'))
self.msg_connect((self.scrambler, 'out'), (self.rs, 'in'))
self.msg_connect((self.rs, 'out'), (self, 'out'))
if crc:
self.msg_connect((self.rs, 'out'), (self.crc, 'in'))
self.msg_connect((self.crc, 'ok'), (self, 'out'))
else:
self.msg_connect((self.rs, 'out'), (self, 'out'))

_default_sync_threshold = 8

Expand All @@ -65,3 +77,4 @@ def add_options(cls, parser):
"""
parser.add_argument('--syncword_threshold', type = int, default = cls._default_sync_threshold, help = 'Syncword bit errors [default=%(default)r]')
parser.add_argument('--verbose_rs', action = 'store_true', help = 'Verbose RS decoder')
parser.add_argument('--verbose_crc', action = 'store_true', help = 'Verbose CRC decoder')
33 changes: 26 additions & 7 deletions python/components/deframers/smogp_ra_deframer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
#

from gnuradio import gr, digital
from ... import decode_ra_code
from ... import decode_ra_code, check_tt64_crc
from ...hier.sync_to_pdu_soft import sync_to_pdu_soft
from ...utils.options_block import options_block

_syncword = '0010110111010100'
_syncword_new = '001011011101010001100011110001010011010110011001'

fec_sizes = {128: 260, 256: 514}

class smogp_ra_deframer(gr.hier_block2, options_block):
Expand All @@ -25,10 +27,12 @@ class smogp_ra_deframer(gr.hier_block2, options_block):
Args:
frame_size: size of the frame before FEC (int)
new_protocol: enable new protocol used in SMOG-1 (bool)
syncword_threshold: number of bit errors allowed in syncword (int)
options: Options from argparse
"""
def __init__(self, frame_size, syncword_threshold = None, options = None):
def __init__(self, frame_size, new_protocol = False,
syncword_threshold = None, options = None):
gr.hier_block2.__init__(self, "smogp_ra_deframer",
gr.io_signature(1, 1, gr.sizeof_float),
gr.io_signature(0, 0, 0))
Expand All @@ -37,22 +41,37 @@ def __init__(self, frame_size, syncword_threshold = None, options = None):
self.message_port_register_hier_out('out')

if syncword_threshold is None:
syncword_threshold = self.options.syncword_threshold
syncword_threshold = self.options.ra_syncword_threshold
if syncword_threshold < 0:
syncword_threshold = self._default_sync_threshold_new if new_protocol \
else self._default_sync_threshold_old

syncword = _syncword_new if new_protocol else _syncword
self.deframer = sync_to_pdu_soft(packlen = fec_sizes[frame_size] * 8,\
sync = _syncword,\
sync = syncword,\
threshold = syncword_threshold)
self.fec = decode_ra_code(frame_size)
if new_protocol:
# CRC-16 ARC
self.crc = check_tt64_crc(verbose = self.options.verbose_crc,
packet_len = None)

self.connect(self, self.deframer)
self.msg_connect((self.deframer, 'out'), (self.fec, 'in'))
self.msg_connect((self.fec, 'out'), (self, 'out'))
if new_protocol:
self.msg_connect((self.fec, 'out'), (self.crc, 'in'))
self.msg_connect((self.crc, 'ok'), (self, 'out'))
else:
self.msg_connect((self.fec, 'out'), (self, 'out'))

_default_sync_threshold = 0
_default_sync_threshold = -1
_default_sync_threshold_old = 0
_default_sync_threshold_new = 6

@classmethod
def add_options(cls, parser):
"""
Adds SMOG-P RA deframer specific options to the argparse parser
"""
parser.add_argument('--syncword_threshold', type = int, default = cls._default_sync_threshold, help = 'Syncword bit errors [default=%(default)r]')
parser.add_argument('--ra_syncword_threshold', type = int, default = cls._default_sync_threshold, help = 'RA syncword bit errors [default=%(default)r]')
parser.add_argument('--verbose_crc', action = 'store_true', help = 'Verbose CRC decoder')
17 changes: 13 additions & 4 deletions python/components/deframers/smogp_signalling_deframer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from ...utils.options_block import options_block

_syncword = '0010110111010100100101111111110111010011011110110000111100011111'
_syncword_tx = '0010110111010100101000111001111000011010010101010110101111001011'

class smogp_signalling_deframer(gr.hier_block2, options_block):
"""
Expand All @@ -22,10 +23,11 @@ class smogp_signalling_deframer(gr.hier_block2, options_block):
with signalling frames.
Args:
new_protocol: enable new protocol used in SMOG-1 (bool)
syncword_threshold: number of bit errors allowed in syncword (int)
options: Options from argparse
"""
def __init__(self, syncword_threshold = None, options = None):
def __init__(self, new_protocol = False, syncword_threshold = None, options = None):
gr.hier_block2.__init__(self, "smogp_signalling_deframer",
gr.io_signature(1, 1, gr.sizeof_float),
gr.io_signature(0, 0, 0))
Expand All @@ -34,21 +36,28 @@ def __init__(self, syncword_threshold = None, options = None):
self.message_port_register_hier_out('out')

if syncword_threshold is None:
syncword_threshold = self.options.syncword_threshold
syncword_threshold = self.options.signalling_syncword_threshold

self.slicer = digital.binary_slicer_fb()
self.deframer = sync_to_pdu_packed(packlen = 64,\
sync = _syncword,\
threshold = syncword_threshold)
if new_protocol:
self.deframer_tx = sync_to_pdu_packed(packlen = 64,\
sync = _syncword_tx,\
threshold = syncword_threshold)

self.connect(self, self.slicer, self.deframer)
self.msg_connect((self.deframer, 'out'), (self, 'out'))

if new_protocol:
self.connect(self.slicer, self.deframer_tx)
self.msg_connect((self.deframer_tx, 'out'), (self, 'out'))

_default_sync_threshold = 8

@classmethod
def add_options(cls, parser):
"""
Adds SMOG-P signalling deframer specific options to the argparse parser
"""
parser.add_argument('--syncword_threshold', type = int, default = cls._default_sync_threshold, help = 'Syncword bit errors [default=%(default)r]')
parser.add_argument('--signalling_syncword_threshold', type = int, default = cls._default_sync_threshold, help = 'Signalling syncword bit errors [default=%(default)r]')
8 changes: 8 additions & 0 deletions python/core/gr_satellites_flowgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,11 @@ def add_options(cls, parser, file = None, name = None, norad = None):
'Astrocast FX.25 NRZ' : set_options(deframers.astrocast_fx25_deframer, nrzi = False),
'AO-40 FEC' : deframers.ao40_fec_deframer,
'AO-40 FEC short' : set_options(deframers.ao40_fec_deframer, short_frames = True),
'AO-40 FEC CRC-16-ARC' : set_options(deframers.ao40_fec_deframer,
crc = True),
'AO-40 FEC CRC-16-ARC short' : set_options(deframers.ao40_fec_deframer,
short_frames = True,
crc = True),
'AO-40 uncoded' : deframers.ao40_uncoded_deframer,
'TT-64' : deframers.tt64_deframer,
'ESEO' : deframers.eseo_deframer,
Expand All @@ -388,7 +393,10 @@ def add_options(cls, parser, file = None, name = None, norad = None):
'NGHam' : set_options(deframers.ngham_deframer, decode_rs = True),
'NGHam no Reed Solomon' : set_options(deframers.ngham_deframer, decode_rs = False),
'SMOG-P RA' : deframers.smogp_ra_deframer,
'SMOG-1 RA' : set_options(deframers.smogp_ra_deframer, new_protocol = True),
'SMOG-P Signalling' : deframers.smogp_signalling_deframer,
'SMOG-1 Signalling' : set_options(deframers.smogp_signalling_deframer,
new_protocol = True),
'OPS-SAT' : deframers.ops_sat_deframer,
'U482C' : deframers.u482c_deframer,
'UA01' : deframers.ua01_deframer,
Expand Down
Loading

0 comments on commit 1ac3e9e

Please sign in to comment.