Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitfields #12

Closed
thesamprice opened this issue Dec 15, 2015 · 1 comment
Closed

Bitfields #12

thesamprice opened this issue Dec 15, 2015 · 1 comment

Comments

@thesamprice
Copy link

Not sure how I would do this with the DataStream object.
In python / C I would do something like

class CCSDS_PriHdr_t_StreamId (my_endian):
    """Some comments"""
    _pack_ = 1
    _fields_ = [ ("packet_version_number"    , ctypes.c_ushort ,3),
                 ("packet_type"              , ctypes.c_ushort ,1),
                 ("secondary_header_present" , ctypes.c_ushort ,1),
                 ("apid"                     , ctypes.c_ushort ,11)]

This would create a 16 bit ctype structure with 4 fields of bits 3,1,1,11.
Trying to stream data from an embedded device and then decode it in a browser.

@kig
Copy link
Owner

kig commented Dec 25, 2015

Yeah, this would be cool to have. Some way to pack & read data by bit. I've got a single-bit access helper at https://github.com/kig/bitview.js, but it doesn't do "treat these 3 bits as the LSBs of an uint".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants