Skip to content

Conversation

@khusmann
Copy link
Owner

@khusmann khusmann commented May 4, 2025

So far, this is just a sketch how I might implement framing for bitfields.

Example usage:

kissFraming = SimpleFraming(
    delimiter=0xC0,
    escape_byte=0xDB,
    escape_map={
        0xC0: 0xDC,  # Frame delimiter
        0xDB: 0xDD,  # Escape byte
    },
)

class Foo(bd.Bitfield):
    a: int = bd.uint_field(4)
    b: int = bd.uint_field(4)

framer = BitfieldFramer(Foo, kissFraming)

foo = Foo(a=1, b=2)

framer.to_bytes([foo, foo, foo])
# b"\xC0\x12\xC0\xC0\x12\xC0\xC0\x12\xC0"

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants