Skip to content

Commit

Permalink
Add SatYAML parameters for CCSDS deframers
Browse files Browse the repository at this point in the history
This eliminates all the framing variants of the CCSDS codes, leaving
only the CCSDS concatenated and the CCSDS Reed-Solomon framing. The
variants are specified by using the following parameters in the
SatYAML:

precoding: differential. If not specified, differential precoding is
  not used.
RS base: either "conventional" or "dual". This is mandatory
RS interleaving: interleave depth. This defaults to 1 if not specified.
scrambler: either "CCSDS" or "none". This defaults to "CCSDS" if not specified.
convolutional: one of "CCSDS", "NASA-DSN", "CCSDS uninverted", "NASA-DSN uninverted".
  This defaults to "CCSDS" if not specified.
  • Loading branch information
daniestevez committed Nov 5, 2020
1 parent 49edced commit 48dd969
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,34 @@ parameters:
label: Frame size (bytes)
dtype: int
default: 223
- id: differential
label: Differential encoding
dtype: bool
default: 'False'
options: ['True', 'False']
- id: dual_basis
label: Use RS dual basis
dtype: bool
default: 'False'
options: ['True', 'False']
- id: use_scrambler
label: Use scrambler
dtype: bool
default: 'True'
options: ['True', 'False']
- id: nasa_dsn
label: Convolutional code
- id: precoding
label: Precoding
dtype: enum
default: 'False'
options: ['False', 'True']
option_labels: [CCSDS/NASA-GSFC, NASA-DSN]
default: 'None'
options: ['None', '"differential"']
option_labels: ['None', 'Differential']
- id: rs_basis
label: Reed-Solomon basis
dtype: enum
default: 'dual'
options: ['conventional', 'dual']
option_labels: [Conventional, Dual]
- id: rs_interleaving
label: Reed-Solomon interleave depth
default: 1
dtype: int
- id: scrambler
label: Scrambler
dtype: enum
default: 'CCSDS'
options: ['CCSDS', 'none']
option_labels: [CCSDS, None]
- id: convolutional
label: Convoluational code
dtype: enum
default: 'CCSDS'
options: ['CCSDS', 'NASA-DSN', 'CCSDS uninverted', 'NASA-DSN uninverted']
option_labels: [CCSDS, NASA-DSN, CCSDS uninverted, NASA-DSN uninverted]
- id: threshold
label: Syncword threshold
dtype: int
Expand All @@ -48,7 +55,7 @@ outputs:

templates:
imports: import satellites.components.deframers
make: satellites.components.deframers.ccsds_concatenated_deframer(frame_size = ${frame_size}, differential = ${differential}, dual_basis = ${dual_basis}, use_scrambler = ${use_scrambler}, nasa_dsn = ${nasa_dsn}, syncword_threshold = ${threshold}, options=${options})
make: satellites.components.deframers.ccsds_concatenated_deframer(frame_size = ${frame_size}, precoding = ${precoding}, rs_basis = ${rs_basis}, rs_interleaving = ${rs_interleaving}, scrambler = ${scrambler}, convolutional = ${convolutional}, syncword_threshold = ${threshold}, options=${options})

documentation: |-
Deframes a signal using the CCSDS concatenated TM protocol
Expand All @@ -61,10 +68,12 @@ documentation: |-
Parameters:
Frame size (bytes): the size of the frame in bytes, after Reed-Solomon decoding
Differential encoding: toggles the usage of differential decoding
Use RS dual basis: toggles the usage of the dual basis definition for the Reed-Solomon code
Precoding: selects no precoding or differential precoding
Reed-Solomon basis: toggles the usage of the conventional or dual basis definition for the Reed-Solomon code
Reed-Solomon interleave depth: number of interleaved Reed-Solomon codewords
Scrambler: enables or disables the CCSDS synchronous scrambler
Convolutional code: selects the polynomials and inversion branches used to define the convolutional encoder
Syncword threshold: number of bit errors to allow in the detection of the 32 bit syncword
Convolutional code: choice of CCSDS/NASA-GSFC (default) or NASA-DSN convention for the convolutional code
Command line options: options to pass down to the block, following the syntax of the gr_satellites command line tool
file_format: 1
45 changes: 27 additions & 18 deletions grc/components/deframers/satellites_ccsds_rs_deframer.block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,28 @@ parameters:
label: Frame size (bytes)
dtype: int
default: 223
- id: differential
label: Differential encoding
dtype: bool
default: 'False'
options: ['True', 'False']
- id: dual_basis
label: Use dual basis
dtype: bool
default: 'False'
options: ['True', 'False']
- id: use_scrambler
label: Use scrambler
dtype: bool
default: 'True'
options: ['True', 'False']
- id: precoding
label: Precoding
dtype: enum
default: 'None'
options: ['None', '"differential"']
option_labels: [None, Differential]
- id: rs_basis
label: Reed-Solomon basis
dtype: enum
default: 'dual'
options: ['conventional', 'dual']
option_labels: [Conventional, Dual]
- id: rs_interleaving
label: Reed-Solomon interleave depth
default: 1
dtype: int
- id: scrambler
label: Scrambler
dtype: enum
default: 'CCSDS'
options: ['CCSDS', 'none']
option_labels: [CCSDS, None]
- id: threshold
label: Syncword threshold
dtype: int
Expand All @@ -42,7 +49,7 @@ outputs:

templates:
imports: import satellites.components.deframers
make: satellites.components.deframers.ccsds_rs_deframer(frame_size = ${frame_size}, differential = ${differential}, dual_basis = ${dual_basis}, use_scrambler = ${use_scrambler}, syncword_threshold = ${threshold}, options=${options})
make: satellites.components.deframers.ccsds_rs_deframer(frame_size = ${frame_size}, precoding = ${precoding}, rs_basis = ${rs_basis}, rs_interleaving = ${rs_interleaving}, scrambler = ${scrambler}, syncword_threshold = ${threshold}, options=${options})

documentation: |-
Deframes a signal using the CCSDS Reed-Solomon TM protocol
Expand All @@ -55,8 +62,10 @@ documentation: |-
Parameters:
Frame size (bytes): the size of the frame in bytes, after Reed-Solomon decoding
Differential encoding: toggles the usage of differential decoding
Use RS dual basis: toggles the usage of the dual basis definition for the Reed-Solomon code
Precoding: selects no precoding or differential precoding
Reed-Solomon basis: toggles the usage of the conventional or dual basis definition for the Reed-Solomon code
Reed-Solomon interleave depth: number of interleaved Reed-Solomon codewords
Scrambler: enables or disables the CCSDS synchronous scrambler
Syncword threshold: number of bit errors to allow in the detection of the 32 bit syncword
Command line options: options to pass down to the block, following the syntax of the gr_satellites command line tool
Expand Down
26 changes: 14 additions & 12 deletions python/components/deframers/ccsds_concatenated_deframer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ class ccsds_concatenated_deframer(gr.hier_block2, options_block):
Args:
frame_size: frame size (not including parity check bytes) (int)
differential: whether to use differential coding (bool)
dual_basis: use dual basis instead of conventional (bool)
use_scrambler: use CCSDS synchronous scrambler (bool)
nasa_dsn: use NASA-DSN instead of CCSDS/NASA-GSFC convolutional code (bool)
precoding: either None or 'differential' for differential precoding (str)
rs_basis: Reed-Solomon basis, either 'conventional' or 'dual' (str)
rs_interleaving: Reed-Solomon interleaving depth (int)
scrambler: scrambler to use, either 'CCSDS' or 'none' (str)
convolutional: convolutional code to use, one of the following:
'CCSDS', 'NASA-DSN', 'CCSDS uninverted', 'NASA-DSN uninverted' (str)
syncword_threshold: number of bit errors allowed in syncword (int)
options: Options from argparse
"""
def __init__(self, frame_size = 223, differential = False, dual_basis = False,
use_scrambler = True, nasa_dsn = False,
def __init__(self, frame_size = 223, precoding = None, rs_basis = 'dual',
rs_interleaving = 1, scrambler = 'CCSDS', convolutional = 'CCSDS',
syncword_threshold = None, options = None):
gr.hier_block2.__init__(self, "ccsds_concatenated_deframer",
gr.io_signature(1, 1, gr.sizeof_float),
Expand All @@ -41,16 +43,16 @@ def __init__(self, frame_size = 223, differential = False, dual_basis = False,
self.message_port_register_hier_out('out')

self.delay1 = blocks.delay(gr.sizeof_float, 1)
self.viterbi0 = ccsds_viterbi(nasa_dsn = nasa_dsn)
self.viterbi1 = ccsds_viterbi(nasa_dsn = nasa_dsn)
self.viterbi0 = ccsds_viterbi(convolutional)
self.viterbi1 = ccsds_viterbi(convolutional)
self.char2float0 = blocks.char_to_float(1, 1)
self.char2float1 = blocks.char_to_float(1, 1)
self.addconst0 = blocks.add_const_ff(-0.5)
self.addconst1 = blocks.add_const_ff(-0.5)
self.rs0 = ccsds_rs_deframer(frame_size, differential, dual_basis,
use_scrambler, syncword_threshold, options)
self.rs1 = ccsds_rs_deframer(frame_size, differential, dual_basis,
use_scrambler, syncword_threshold, options)
self.rs0 = ccsds_rs_deframer(frame_size, precoding, rs_basis, rs_interleaving,
scrambler, syncword_threshold, options)
self.rs1 = ccsds_rs_deframer(frame_size, precoding, rs_basis, rs_interleaving,
scrambler, syncword_threshold, options)

self.connect(self, self.viterbi0, self.char2float0, self.addconst0, self.rs0)
self.connect(self, self.delay1, self.viterbi1, self.char2float1, self.addconst1, self.rs1)
Expand Down
33 changes: 21 additions & 12 deletions python/components/deframers/ccsds_rs_deframer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,52 @@ class ccsds_rs_deframer(gr.hier_block2, options_block):
Args:
frame_size: frame size (not including parity check bytes) (int)
differential: whether to use differential coding (bool)
dual_basis: use dual basis instead of conventional (bool)
use_scrambler: use CCSDS synchronous scrambler (bool)
precoding: either None or 'differential' for differential precoding (str)
rs_basis: Reed-Solomon basis, either 'conventional' or 'dual' (str)
rs_interleaving: Reed-Solomon interleaving depth (int)
scrambler: scrambler to use, either 'CCSDS' or 'none' (str)
syncword_threshold: number of bit errors allowed in syncword (int)
options: Options from argparse
"""
def __init__(self, frame_size = 223, differential = False, dual_basis = False,
use_scrambler = True, syncword_threshold = None, options = None):
def __init__(self, frame_size = 223, precoding = None, rs_basis = 'dual',
rs_interleaving = 1, scrambler = 'CCSDS',
syncword_threshold = None, options = None):
gr.hier_block2.__init__(self, "ccsds_rs_deframer",
gr.io_signature(1, 1, gr.sizeof_float),
gr.io_signature(0, 0, 0))
options_block.__init__(self, options)

if precoding not in [None, 'differential']:
raise ValueError(f'invalid precoding {precoding}')
if rs_basis not in ['conventional', 'dual']:
raise ValueError(f'invalid Reed-Solomon basis {rs_basis}')
if scrambler not in ['CCSDS', 'none']:
raise ValueError(f'invalid scrambler {scrambler}')

self.message_port_register_hier_out('out')

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

self.slicer = digital.binary_slicer_fb()
if differential:
if precoding == 'differential':
self.differential = digital.diff_decoder_bb(2)
deframe_func = sync_to_pdu if use_scrambler else sync_to_pdu_packed
packlen_mult = 8 if use_scrambler else 1
deframe_func = sync_to_pdu if scrambler == 'CCSDS' else sync_to_pdu_packed
packlen_mult = 8 if scrambler == 'CCSDS' else 1
self.deframer = deframe_func(packlen = (frame_size + 32) * packlen_mult,
sync = _syncword,
threshold = syncword_threshold)
if use_scrambler:
if scrambler == 'CCSDS':
self.scrambler = ccsds_descrambler()
self.fec = decode_rs(dual_basis, 1)
self.fec = decode_rs(rs_basis == 'dual', rs_interleaving)

self._blocks = [self, self.slicer]
if differential:
if precoding == 'differential':
self._blocks.append(self.differential)
self._blocks += [self.deframer]

self.connect(*self._blocks)
if use_scrambler:
if scrambler == 'CCSDS':
self.msg_connect((self.deframer, 'out'), (self.scrambler, 'in'))
self.msg_connect((self.scrambler, 'out'), (self.fec, 'in'))
else:
Expand Down
29 changes: 6 additions & 23 deletions python/core/gr_satellites_flowgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ def __init__(self, file = None, name = None, norad = None, samp_rate = None, iq
demod_options = {k : k for k in demod_options}
demodulator_additional_options = filter_translate_dict(transmitter, demod_options)
demodulator = self.get_demodulator(transmitter['modulation'])(baudrate = baudrate, samp_rate = samp_rate, iq = iq, dump_path = dump_path, options = options, **demodulator_additional_options)
deframe_options = {'frame size' : 'frame_size'}
deframe_options = { 'frame size' : 'frame_size',
'precoding' : 'precoding',
'RS basis' : 'rs_basis',
'RS interleaving' : 'rs_interleaving',
'convolutional' : 'convolutional',
'scrambler' : 'scrambler' }
deframer_additional_options = filter_translate_dict(transmitter, deframe_options)
deframer = self.get_deframer(transmitter['framing'])(options = options, **deframer_additional_options)
self.connect(self, demodulator, deframer)
Expand Down Expand Up @@ -284,29 +289,7 @@ def add_options(cls, parser, file = None, name = None, norad = None):
'NuSat' : deframers.nusat_deframer,
'K2SAT' : deframers.k2sat_deframer,
'CCSDS Reed-Solomon' : deframers.ccsds_rs_deframer,
'CCSDS Reed-Solomon dual' : set_options(deframers.ccsds_rs_deframer, dual_basis = True),
'CCSDS Reed-Solomon differential' : set_options(deframers.ccsds_rs_deframer, differential = True),
'CCSDS Reed-Solomon dual differential' : set_options(deframers.ccsds_rs_deframer, differential = True, dual_basis = True),
'CCSDS Concatenated' : deframers.ccsds_concatenated_deframer,
'CCSDS Concatenated dual' : set_options(deframers.ccsds_concatenated_deframer, dual_basis = True),
'CCSDS Concatenated differential' : set_options(deframers.ccsds_concatenated_deframer, differential = True),
'CCSDS Concatenated dual differential' : set_options(deframers.ccsds_concatenated_deframer, differential = True, dual_basis = True),
'NASA-DSN Concatenated' : set_options(deframers.ccsds_concatenated_deframer, nasa_dsn = True),
'NASA-DSN Concatenated dual' : set_options(deframers.ccsds_concatenated_deframer, dual_basis = True, nasa_dsn = True),
'NASA-DSN Concatenated differential' : set_options(deframers.ccsds_concatenated_deframer, differential = True, nasa_dsn = True),
'NASA-DSN Concatenated dual differential' : set_options(deframers.ccsds_concatenated_deframer, differential = True, dual_basis = True, nasa_dsn = True),
'CCSDS Reed-Solomon no-scrambler' : set_options(deframers.ccsds_rs_deframer, use_scrambler = False),
'CCSDS Reed-Solomon dual no-scrambler' : set_options(deframers.ccsds_rs_deframer, dual_basis = True, use_scrambler = False),
'CCSDS Reed-Solomon differential no-scrambler' : set_options(deframers.ccsds_rs_deframer, differential = True, use_scrambler = False),
'CCSDS Reed-Solomon dual differential no-scrambler' : set_options(deframers.ccsds_rs_deframer, differential = True, dual_basis = True, use_scrambler = False),
'CCSDS Concatenated no-scrambler' : set_options(deframers.ccsds_concatenated_deframer, use_scrambler = False),
'CCSDS Concatenated dual no-scrambler' : set_options(deframers.ccsds_concatenated_deframer, dual_basis = True, use_scrambler = False),
'CCSDS Concatenated differential no-scrambler' : set_options(deframers.ccsds_concatenated_deframer, differential = True, use_scrambler = False),
'CCSDS Concatenated dual differential no-scrambler' : set_options(deframers.ccsds_concatenated_deframer, differential = True, dual_basis = True, use_scrambler = False),
'NASA-DSN Concatenated no-scrambler' : set_options(deframers.ccsds_concatenated_deframer, use_scrambler = False, nasa_dsn = True),
'NASA-DSN Concatenated dual no-scrambler' : set_options(deframers.ccsds_concatenated_deframer, dual_basis = True, use_scrambler = False, nasa_dsn = True),
'NASA-DSN Concatenated differential no-scrambler' : set_options(deframers.ccsds_concatenated_deframer, differential = True, use_scrambler = False, nasa_dsn = True),
'NASA-DSN Concatenated dual differential no-scrambler' : set_options(deframers.ccsds_concatenated_deframer, differential = True, dual_basis = True, use_scrambler = False, nasa_dsn = True),
'LilacSat-1' : deframers.lilacsat_1_deframer,
'AAUSAT-4' : deframers.aausat4_deframer,
'NGHam' : set_options(deframers.ngham_deframer, decode_rs = True),
Expand Down
11 changes: 8 additions & 3 deletions python/hier/ccsds_viterbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


class ccsds_viterbi(gr.hier_block2):
def __init__(self, nasa_dsn = False):
def __init__(self, code = 'CCSDS'):
gr.hier_block2.__init__(
self, "CCSDS/NASA-GSFC Viterbi decoder",
gr.io_signature(1, 1, gr.sizeof_float*1),
Expand All @@ -29,8 +29,13 @@ def __init__(self, nasa_dsn = False):
##################################################
# Variables
##################################################
polys = [-109, 79] if nasa_dsn else [79, -109]
self.dec_cc = dec_cc = fec.cc_decoder.make(80,7, 2, polys, 0, -1, fec.CC_STREAMING, False)
polys = {'CCSDS' : [79, -109],
'NASA-DSN' : [-109, 79],
'CCSDS uninverted' : [79, 109],
'NASA-DSN uninverted' : [109, 79],
}
self.dec_cc = dec_cc = fec.cc_decoder.make(80, 7, 2, polys[code],
0, -1, fec.CC_STREAMING, False)

##################################################
# Blocks
Expand Down
4 changes: 3 additions & 1 deletion python/satyaml/BY70-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ transmitters:
frequency: 436.200e+6
modulation: BPSK
baudrate: 9600
framing: CCSDS Concatenated differential
framing: CCSDS Concatenated
precoding: differential
RS basis: conventional
frame size: 114
transports:
- *kiss
3 changes: 2 additions & 1 deletion python/satyaml/KS-1Q.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ transmitters:
frequency: 436.500e+6
modulation: FSK
baudrate: 20000
framing: CCSDS Concatenated dual
framing: CCSDS Concatenated
RS basis: dual
frame size: 223
transports:
- *kiss
6 changes: 5 additions & 1 deletion python/satyaml/LilacSat-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ transmitters:
frequency: 437.200e+6
modulation: BPSK
baudrate: 9600
framing: CCSDS Concatenated differential
framing: CCSDS Concatenated
precoding: differential
RS basis: conventional
frame size: 114
transports:
- *kiss
Expand All @@ -30,6 +32,7 @@ transmitters:
modulation: FSK
baudrate: 4800
framing: CCSDS Concatenated
RS basis: conventional
frame size: 114
transports:
- *kiss2
Expand All @@ -38,6 +41,7 @@ transmitters:
modulation: FSK subaudio
baudrate: 300
framing: CCSDS Reed-Solomon
RS basis: conventional
frame size: 114
transports:
- *kiss3
4 changes: 3 additions & 1 deletion python/satyaml/TRISAT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ transmitters:
frequency: 435.6125e+6
modulation: FSK
baudrate: 9766
framing: NASA-DSN Concatenated dual
framing: CCSDS Concatenated
RS basis: dual
convolutional: NASA-DSN
frame size: 223
data:
- *tlm
Loading

0 comments on commit 48dd969

Please sign in to comment.