DataStream.js
DataStream.js copied to clipboard
Bitfields
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.
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".