spacepackets-py
spacepackets-py copied to clipboard
Packet type (bit 3) and secondary header flag (bit 4) appear to be swapped in your API?
@robamu @JakobMeier
Hi ~ My understanding per the standard is that packet_type
should correlate to bit three and sec_header_flag
should correlate to bit four. However, w/ your API it's as if you've got these two swapped around. Hopefully, I've misinterpreted something.
Here's how to replicate my findings. As you'll see below, when I set packet_type to 1 then bit 4 will flip and when I set secondary header flag to 1 then bit 3 will flip.
#
# TEST PACKET TYPE
#
# Lets set packet_type to one, and leave everything else set to 0
>>> hdr = SpacePacketHeader(packet_type=1,apid=0,seq_count=0,data_len=0,sec_header_flag=0, seq_flags=0)
# here we see that bit 4 is set
>>> print(','.join([bin(i) for i in hdr.pack()]))
0b10000,0b0,0b0,0b0,0b0,0b0
# here is what I think it should be
0b1000,0b0,0b0,0b0,0b0,0b0
#
# TEST SECONDARY HEADER FLAG
#
# Lets set sec_header_flag to one and leave everything else set to 0
>>> hdr = SpacePacketHeader(packet_type=0,apid=0,seq_count=0,data_len=0,sec_header_flag=1, seq_flags=0)
# here we see that bit 3 is set
>>> print(','.join([bin(i) for i in hdr.pack()]))
0b1000,0b0,0b0,0b0,0b0,0b0
# here is what I think it should be
0b10000,0b0,0b0,0b0,0b0,0b0
I doubt my environment matters but to be thorough here is my complete setup on my laptop including package version, python version, and operating system information.
☕ ❯ pip3 show spacepackets
Name: spacepackets
Version: 0.22.0
Summary: Various CCSDS and ECSS packet implementations
Home-page:
Author:
Author-email: Robin Mueller <[email protected]>
License: Apache-2.0
Location: /home/shane/.local/lib/python3.10/site-packages
Requires: crcmod, deprecation
Required-by:
☕ ❯ python3 --version
Python 3.10.12
☕ ❯ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
The output looks correct. The primary header fields are placed contiguously, with the first 3 bits (bit 0 to 2) being the version number, then bit 3 as packet type and bit 4 as secondary header flag.
The first byte is 0b00010000 for the first example , so bit 3 is one, which is correct.