Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ASRTU-1 #672

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ include(GrPython)
GR_PYTHON_INSTALL(
PROGRAMS
gr_satellites
erminaz_ssdv
jy1sat_ssdv
gr_satellites_ssdv
smog_p_spectrum
DESTINATION bin
)
88 changes: 0 additions & 88 deletions apps/erminaz_ssdv

This file was deleted.

136 changes: 136 additions & 0 deletions apps/gr_satellites_ssdv
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright 2019-2020, 2024 Daniel Estevez <[email protected]>
#
# This file is part of gr-satellites
#
# SPDX-License-Identifier: GPL-3.0-or-later
#

import argparse
from enum import Enum
import struct
import subprocess
import sys

import numpy as np

from satellites.kiss import *
from satellites.telemetry.by02 import TMPrimaryHeader as TMPrimaryHeaderShort
from satellites.telemetry.erminaz import TMPrimaryHeader


class Satellite(Enum):
JY1SAT = 'JY1SAT'
ERMINAZ = 'ERMINAZ'
DSLWP = 'DSLWP'

def __str__(self):
return self.value


def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
'--satellite', type=Satellite, choices=list(Satellite),
help='Satellite')
parser.add_argument('input', help='Input KISS file')
parser.add_argument(
'output',
help='Output filenames (start of filenames)')
return parser.parse_args()


def seqnum(packet, satellite):
offsets = {
Satellite.JY1SAT: 3,
Satellite.ERMINAZ: 8,
Satellite.DSLWP: 1,
}
off = offsets[satellite]
return struct.unpack('>H', packet[off:off+2])[0]


def read_kiss_file(path, framesize=None):
frames = list()
frame = list()
transpose = False
with open(path, 'rb') as f:
for c in f.read():
if c == FEND:
if ((framesize is None or len(frame) == framesize + 1)
and len(frame) > 1
and (frame[0] & 0x0f) == 0):
frames.append(frame[1:])
frame = list()
elif transpose:
if c == TFEND:
frame.append(FEND)
elif c == TFESC:
frame.append(FESC)
transpose = False
elif c == FESC:
transpose = True
else:
frame.append(c)
return np.array(frames, dtype='uint8')


def main():
args = parse_args()

# Read frames
framesizes = {Satellite.JY1SAT: 256}
framesize = framesizes.get(args.satellite)
x = read_kiss_file(args.input, framesize)

if args.satellite == Satellite.JY1SAT:
# Filter out by frame id and trim to payload
x = x[((x[:, 0] == 0xe0) | (x[:, 0] == 0xe1)) & (x[:, 1] == 0x10), 56:]

# Filter SSDV packets
x = x[(x[:, 0] == 0x55) & (x[:, 1] == 0x68), :]
elif args.satellite == Satellite.ERMINAZ:
vcid = 4
headers = [TMPrimaryHeader.parse(y) for y in x]
x = np.array([y for h, y in zip(headers, x)
if h.virtual_channel_id == vcid])
x = x[:, TMPrimaryHeader.sizeof() + 2:]
elif args.satellite == Satellite.DSLWP:
vcid = 1
headers = [TMPrimaryHeaderShort.parse(y) for y in x]
x = np.array([y for h, y in zip(headers, x)
if h.virtual_channel_id == vcid])
x = x[:, TMPrimaryHeaderShort.sizeof():]

if x.size == 0:
# there are no SSDV packets
return

id_idxs = {
Satellite.JY1SAT: 2,
Satellite.ERMINAZ: 6,
Satellite.DSLWP: 0,
}
id_idx = id_idxs[args.satellite]
ids = set(x[:, id_idx])

decoder_args = {
Satellite.JY1SAT: ['-J'],
Satellite.ERMINAZ: ['-l', str(x.shape[1])],
Satellite.DSLWP: ['-D'],
}[args.satellite]
for i in ids:
L = list(x[x[:, id_idx] == i, :])
L.sort(key=lambda x: seqnum(x, satellite=args.satellite))
ssdv = '{}_{}.ssdv'.format(args.output, i)
jpeg = '{}_{}.jpg'.format(args.output, i)
np.array(L).tofile(ssdv)
print('Calling SSDV decoder for image {}'.format(hex(i)))
subprocess.call(['ssdv', '-d'] + decoder_args + [ssdv, jpeg])
print()


if __name__ == '__main__':
main()
81 changes: 0 additions & 81 deletions apps/jy1sat_ssdv

This file was deleted.

2 changes: 1 addition & 1 deletion docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ set(MAN_BUILD_DIR ${PROJECT_BINARY_DIR}/docs)

list(APPEND manpages
gr_satellites.1
jy1sat_ssdv.1
gr_satellites_ssdv.1
smog_p_spectrum.1
)

Expand Down
2 changes: 1 addition & 1 deletion docs/gr_satellites.1
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,5 @@ Verbose RS decoder
.BR \-\-telemetry_output\ \fITELEMETRY_OUTPUT\fR
Telemetry output file [default=stdout]
.SH "SEE ALSO"
.BR jy1sat_ssdv (1),
.BR gr_satellites_ssdv (1),
.BR smog_p_spectrum (1)
17 changes: 9 additions & 8 deletions docs/jy1sat_ssdv.1 → docs/gr_satellites_ssdv.1
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
.TH JY1SAT-SSDV 1 2020-09-28 gr-satellites "User commands"
.TH GR-SATELLITES-SSDV 1 2024-10-19 gr-satellites "User commands"
.SH NAME
jy1sat_ssdv \- extracts SSDV images from a KISS file containing frames of the
JY1SAT satellite
gr_satellitest_ssdv \- extracts SSDV images from a KISS file
.SH SYNOPSIS
.B jy1sat_ssdv
.IR jy1sat_frames.kss
.IR output_path
.B gr_satellites_ssdv
.BR \-\-satellite\ \fISATELLITE\fR
.IR input
.IR output
.SH DESCRIPTION
.PP
.B jy1sat_ssdv
.B gr_satellites_ssdv
forms part of gr-satellites and can be used to extract and
decoded SSDV images from a KISS file containing frames from JY1SAT.
decoded SSDV images from a KISS file containing frames from
some satellites.
.PP
gr-satellites is a GNU Radio out-of-tree module encompassing a collection of
telemetry decoders that supports many different Amateur satellites. It supports
Expand Down
5 changes: 5 additions & 0 deletions docs/source/satyaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ The allowable transport protocols are the following:
* ``KISS KS-1Q``, KISS variant used by KS-1Q, which includes a header before the
KISS bytes

* ``TM KISS``, TM frames containing a KISS stream in some virtual channels

* ``TM short KISS``, short (5 byte) TM frames containing a KISS stream in some
virtual channels

.. _YAML: https://yaml.org/
.. _AX.25: http://www.ax25.net/
.. _FX.25: https://en.wikipedia.org/wiki/FX.25_Forward_Error_Correction
Expand Down
1 change: 1 addition & 0 deletions grc/components/transports/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
install(FILES
satellites_kiss_transport.block.yml
satellites_nanolink_transport.block.yml
satellites_tm_kiss_transport.block.yml
DESTINATION share/gnuradio/grc/blocks
)
Loading