It’s all in the docs, but it sure does help to write it out..
This is the first byte, the Fmt byte. Use it to know how much data there is to capture.
0 = optional length byte present, no address bytes
1 to 3f = subtract 0 to get the length, no address bytes
40 = optional length byte present, ?? address bytes unsure [exception mode (CARB)]
41 to 7f – subtract 40 to get length, ?? address bytes unsure [exception mode (CARB)]
80 = optional length byte present, address bytes present [physical addressing]
81 to bf – subtract 80 to get length, address bytes present [physical addressing]
c0 = optional length byte present, address bytes present [functional addressing]
c1 to FF = subtract c0 to get length, address bytes present [functional addressing]
Length = service id bytes (included) to checksum (not included)
Checksum = All bytes except the checksum itself, sum, mod 256.
edit: since writing the above, I have come to understand bitwise operations. Hey, I’m new to this programming stuff! I’ll re-write it soon. Rather than ‘subtract xx’, it makes more sense to deal with it as a series of bits and use bitwise & operators on it. e.g. bitwise & 0x3f for example would tell us if the two most-significant bits were set.. (0x3f being 00111111.. bitwise & 0x3f with 11xxxxx (x being anything) would return all 1s i.e. TRUE).