Skip to content

add support for framing#3

Open
khusmann wants to merge 1 commit intomainfrom
feat-framing
Open

add support for framing#3
khusmann wants to merge 1 commit intomainfrom
feat-framing

Conversation

@khusmann
Copy link
Copy Markdown
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.

1 participant