File: aausat4.py

package info (click to toggle)
gr-satellites 5.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,836 kB
  • sloc: python: 29,546; cpp: 5,448; ansic: 1,247; sh: 118; makefile: 24
file content (79 lines) | stat: -rw-r--r-- 1,606 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright 2019 Daniel Estevez <daniel@destevez.net>
#
# This file is part of gr-satellites
#
# SPDX-License-Identifier: GPL-3.0-or-later
#

from construct import *

from ..adapters import LinearAdapter
from .csp import CSPHeader


EPS = Struct(
    'boot_count' / Int16ub,
    'uptime' / Int32ub,
    'rt_clock' / Int32ub,
    'ping_status' / Int8ub,
    'subsystem_status' / Int16ub,
    'battery_voltage' / LinearAdapter(1/40.0, Int8ub),
    'cell_diff' / LinearAdapter(1/4.0, Int8sb),
    'battery_current' / LinearAdapter(1/10.0, Int8sb),
    'solar_power' / LinearAdapter(1/20.0, Int8ub),
    'temp' / Int8sb,
    'pa_temp' / Int8sb,
    'main_voltage' / Int8sb
    )

COM = Struct(
    'boot_count' / Int16ub,
    'packets_received' / Int16ub,
    'packets_sent' / Int16ub,
    'latest_rssi' / Int16sb,
    'latest_bit_correction' / Int8ub,
    'latest_byte_correction' / Int8ub
    )

# Reverse-engineered

ADCS1 = Struct(
    'bdot' / Int16sb[3],
    'state' / Int8ub
    )

ADCS2 = Struct(
    'gyro' / Int16sb[3]
    )

AIS = Struct(
    'boot_count' / Int16ub,
    Padding(4),  # unknown data
    'unique_mssi' / Int16ub,
    Padding(12)  # unknown data
    )

Valid = BitStruct(
    Padding(2),
    'ais2' / Flag,
    'ais1' / Flag,
    'adcs2' / Flag,
    'adcs1' / Flag,
    'com' / Flag,
    'eps' / Flag
    )

aausat4 = Struct(
    'frame_length' / Int16ub,
    'csp_header' / ByteSwapped(CSPHeader),
    'valid' / Valid,
    'eps' / EPS,
    'com' / COM,
    'adcs1' / ADCS1,
    'adcs2' / ADCS2,
    'ais1' / AIS,
    'ais2' / AIS
    )