Skip to content

Commit

Permalink
add SamSat-Ionosphere support
Browse files Browse the repository at this point in the history
  • Loading branch information
baskiton committed Dec 14, 2024
1 parent bbca95b commit 9a02640
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ The following protocols are currently supported:
* `Ledsat` - [LEDSAT](https://www.s5lab.space/index.php/decoding-ledsat/)
* `Lucky-7` - [Lucky-7 Satellite protocol](https://www.lucky7satellite.org/radioamateurs)
* `RoseyCubeSat`
* `SamSat-Ionosphere` - [SamSat-Ion2 beacon structure](https://spaceresearch.ssau.ru/doc/SamSat/SamSat-Ion2/SamSat-Ionosphere-beacon.pdf)
* `SharjahSat`
* `Sonate-2` - [Sonate-2 protocol](https://www.informatik.uni-wuerzburg.de/en/aerospaceinfo/mitarbeiter/kayal/forschungsprojekte/sonate-2/information-for-radio-amateurs/)
* `WTCSimba` - [WildTrackCube-SIMBA](https://www.s5lab.space/index.php/decoding-simba/)
Expand Down
2 changes: 2 additions & 0 deletions SatsDecoder/systems/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from SatsDecoder.systems.ledsat import *
from SatsDecoder.systems.lucky7 import *
from SatsDecoder.systems.roseycubesat import *
from SatsDecoder.systems.samsat_ion2 import *
from SatsDecoder.systems.sharjahsat import *
from SatsDecoder.systems.sonate2 import *
# from SatsDecoder.systems.starlink_vhf import *
Expand All @@ -35,6 +36,7 @@
'ledsat',
'lucky7',
'roseycubesat',
'samsat_ion2',
'sharjahsat',
'sonate2',
# 'starlink_vhf',
Expand Down
86 changes: 86 additions & 0 deletions SatsDecoder/systems/samsat_ion2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Copyright (c) 2024. Alexander Baskikh
#
# MIT License (MIT), http://opensource.org/licenses/MIT
# Full license can be found in the LICENSE-MIT file
#
# SPDX-License-Identifier: MIT

import construct
from construct import Construct

from SatsDecoder.systems import ax25, common

__all__ = 'SamSatIon2Protocol',

proto_name = 'samsat-ion2'

# SamSat-Ion2 beacon structure
# https://spaceresearch.ssau.ru/doc/SamSat/SamSat-Ion2/SamSat-Ionosphere-beacon.pdf

reg_temp = common.LinearAdapter(256, construct.Int16sl)

unkn = construct.Struct(
'_name' / construct.Computed('samsat_unkn'),
'name' / construct.Computed('Unknown'),
'data' / construct.GreedyBytes,
)
packet = construct.Struct(
'_name' / construct.Computed('samsat_beacon'),
'name' / construct.Computed('Beacon'),
'msg' / construct.PaddedString(6, 'ascii'),
'_pad0' / construct.Bytes(4),
'Tbat1' / reg_temp,
'Tbat2' / reg_temp,
'_pad1' / construct.Bytes(24),
'Mrecv' / construct.Int32ul,
'_pad2' / construct.Bytes(8),
'Ttx1' / reg_temp,
'Ttx2' / reg_temp,
'Ttx3' / reg_temp,
'_pad3' / construct.Bytes(23),
'Tmag' / common.AffineAdapter(333.87, 21.0, construct.Int16sl),
'_tail' / construct.GreedyBytes,
)

samsat = construct.Struct(
'ax25' / construct.Peek(ax25.ax25_header),
'ax25' / construct.If(lambda this: bool(this.ax25), ax25.ax25_header),
'packet' / construct.Peek(packet),
'packet' / construct.If(lambda this: (bool(this.ax25) and this.ax25.pid == 0xF0),
construct.IfThenElse(lambda this: bool(this.packet), packet, unkn)),
)


class SamSatIon2Protocol(common.Protocol):
columns = ()
c_width = ()
tlm_table = {
'samsat_beacon': {
'table': (
('name', 'Name'),
('msg', 'Message'),
('Tbat1', 'Battery #1 temperature, °C'),
('Tbat2', 'Battery #2 temperature, °C'),
('Mrecv', 'Messages received'),
('Ttx1', 'Transceiver #1 temperature, °C'),
('Ttx2', 'Transceiver #2 temperature, °C'),
('Ttx3', 'Transceiver #3 temperature, °C'),
('Tmag', 'Magnetometer temperature, °C'),
)
},
'samsat_unkn': {
'table': (
('name', 'Name'),
('data', 'Data'),
)
}
}

def recognize(self, bb: bytes):
x = samsat.parse(bb)
name = self.get_sender_callsign(x) or 'unknown'
if not x.packet:
yield 'raw', name, bb
return

yield 'tlm', name, (x, x.packet)

0 comments on commit 9a02640

Please sign in to comment.