From b68446c6d20729a0a116c01eeba688d8d6f72e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Est=C3=A9vez?= Date: Fri, 13 Nov 2020 23:34:28 +0100 Subject: [PATCH] Add Lucky-7 image receiver The implementation is based on https://github.com/Xerbo/Lucky7-Decoder This closes #192 --- CHANGELOG.md | 1 + docs/source/command_line.rst | 4 ++-- python/filereceiver/CMakeLists.txt | 1 + python/filereceiver/__init__.py | 1 + python/filereceiver/lucky7.py | 38 ++++++++++++++++++++++++++++++ python/satyaml/Lucky-7.yml | 3 +++ 6 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 python/filereceiver/lucky7.py diff --git a/CHANGELOG.md b/CHANGELOG.md index b4700e58..56c4b1f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for SPOC - PDU add metadata block - Support for AISTECHSAT-2 custom protocol +- Lucky-7 image receiver ### Changed - Replaced boost::bind() by C++ lambdas diff --git a/docs/source/command_line.rst b/docs/source/command_line.rst index 618b9d3d..225cf9e0 100644 --- a/docs/source/command_line.rst +++ b/docs/source/command_line.rst @@ -573,8 +573,8 @@ displayed in real time as they are being received, using `feh`_. Currently the satellites that have decoders supporting file reception are ATL-1 and SMOG-P (they transmit RF spectrum data), and the satellites that have -decoders supporting image reception are 1KUNS-PF, BY70-1, D-SAT, LilacSat-1 and -Światowid. +decoders supporting image reception are 1KUNS-PF, BY70-1, D-SAT, LilacSat-1, +Lucky-7 and Światowid. For satellites supporting file reception, the ``--file_output_path`` parameter can be used to set the directory that is used to store received files. The diff --git a/python/filereceiver/CMakeLists.txt b/python/filereceiver/CMakeLists.txt index 25a5b015..69b95dfd 100644 --- a/python/filereceiver/CMakeLists.txt +++ b/python/filereceiver/CMakeLists.txt @@ -37,6 +37,7 @@ GR_PYTHON_INSTALL( k2sat.py filereceiver.py imagereceiver.py + lucky7.py sat_1kuns_pf.py smogp.py swiatowid.py diff --git a/python/filereceiver/__init__.py b/python/filereceiver/__init__.py index eeed29b6..43ebc79a 100644 --- a/python/filereceiver/__init__.py +++ b/python/filereceiver/__init__.py @@ -18,6 +18,7 @@ from .by70_1 import by70_1 from .dsat import dsat from .k2sat import k2sat +from .lucky7 import lucky7 from .sat_1kuns_pf import sat_1kuns_pf from .smogp import smogp from .swiatowid import swiatowid diff --git a/python/filereceiver/lucky7.py b/python/filereceiver/lucky7.py new file mode 100644 index 00000000..98ea0db7 --- /dev/null +++ b/python/filereceiver/lucky7.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# Copyright 2020 Daniel Estevez +# +# This file is part of gr-satellites +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +# Based on the decoder by Xerbo +# https://github.com/Xerbo/Lucky7-Decoder + +import struct + +from .imagereceiver import ImageReceiver + +class ImageReceiverLucky7(ImageReceiver): + def chunk_sequence(self, chunk): + return struct.unpack('>H', chunk[3:5])[0] + + def chunk_size(self): + return 28 + + def chunk_data(self, chunk): + return chunk[7:] + + def file_size(self, chunk): + return self.chunk_size() * struct.unpack('>H', chunk[5:7])[0] + + def parse_chunk(self, chunk): + address = struct.unpack('>H', chunk[1:3])[0] + if address < 0xC000 \ + or address >= 0xC000 + self.file_size(chunk)/self.chunk_size(): + return None + return chunk + +lucky7 = ImageReceiverLucky7 diff --git a/python/satyaml/Lucky-7.yml b/python/satyaml/Lucky-7.yml index 7d891d39..bb4db6e8 100644 --- a/python/satyaml/Lucky-7.yml +++ b/python/satyaml/Lucky-7.yml @@ -3,6 +3,8 @@ norad: 44406 data: &tlm Telemetry: unknown + &image Image: + image: lucky7 transmitters: 4k8 FSK downlink: frequency: 437.525e+6 @@ -11,3 +13,4 @@ transmitters: framing: Lucky-7 data: - *tlm + - *image