File: aepex_70cm.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 (50 lines) | stat: -rw-r--r-- 1,328 bytes parent folder | download
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
# Copyright 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024  Daniel Estevez
# <daniel@destevez.net>
# Copyright 2024 The Regents of the University of Colorado
#
# This file is part of gr-satellites
#
# SPDX-License-Identifier: GPL-3.0-or-later
#


from datetime import datetime
from construct import Adapter, BitsInteger, BitStruct, Container, Enum, \
    Flag, GreedyBytes, If, Int8ub, Int16ub, Int32ub, \
    Padding, RawCopy, Struct, Switch
from .ax25 import Header
from ..ccsds import space_packet as ccsds_space_packet

from .aepex_sw_stat import aepex_sw_stat

PrimaryHeader = BitStruct(
    'VERSION' / BitsInteger(3),
    'TYPE' / BitsInteger(1),
    'SEC_HDR_FLAG' / BitsInteger(1),
    'PKT_APID' / BitsInteger(11),
    'SEQ_FLGS' / BitsInteger(2),
    'SEQ_CTR' / BitsInteger(14),
    'PKT_LEN' / BitsInteger(16),
)

SecondaryHeader = BitStruct(
    'SHCOARSE' / BitsInteger(32),
    'SHFINE' / BitsInteger(16)
)

aepex_70cm = Struct(
    'ax25_header' / Header,
    'primary_header' / PrimaryHeader,
    'secondary_header' / If(
        lambda c: c.primary_header.SEC_HDR_FLAG,
        SecondaryHeader
    ),
    'packet' / Switch(
        lambda c: c.primary_header.PKT_APID,
        {
            0x01: aepex_sw_stat
        },
        default=GreedyBytes
    )

)