binary-parser icon indicating copy to clipboard operation
binary-parser copied to clipboard

[HELP] Can someone help in understanding how to parse this type of buffer?

Open enricovittorini opened this issue 2 years ago • 1 comments

Hello Guys, can someone explain how to parse a buffer with this structure?

image

I managed to do it till here:

const patParse = new Parser()
         .uint8("table_id")
         .bit1("section_syntax_indicator")
         .bit1("zero")
         .bit2("reserved")
         .bit12("section_length")
         .uint16("transport_stream_id")
         .bit2("reserved")
         .bit5("version_number")
         .bit1("current_next_indicator")
         .uint8("section_number")
         .uint8("last_section_number")

but I do not know how to manage the "for"/"if" with unknown length.

thanks for your help!

enricovittorini avatar Jun 04 '22 05:06 enricovittorini

If you know the size of the buffer, you could calculate the number of elements (N) and pass it to the length or lengthInBytes option of the array parser.

keichi avatar Jun 05 '22 13:06 keichi