Skip to content

Instantly share code, notes, and snippets.

@generalmimon
Last active July 2, 2020 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save generalmimon/54d3a53d1cdfaa4e4d594d36035f077a to your computer and use it in GitHub Desktop.
Save generalmimon/54d3a53d1cdfaa4e4d594d36035f077a to your computer and use it in GitHub Desktop.
The recommended way of handling the situation described in https://www.systemticks.de/2020/06/09/dlt-parser-from-kaitai.html#known-issues-and-possible-improvements using KSY
# listing 4
seq:
- id: payload
type: type_info
size: 4 # not strictly necessary, but it's safer to wrap the `type_info` into the substream like this,
# because if the bitfields `types/type_info/seq` wouldn't fill the whole 4 bytes, it would still work
# (see https://doc.kaitai.io/user_guide.html#_streams_and_substreams)
types:
type_info:
seq:
- id: floa
type: b1 # note that the value of the `b1` field used like this will be automatically translated to boolean type (`true` or `false`),
# so you can save those `== 1` comparisons
- id: uint
type: b1 # equivalent of (inforaw & 0b01000000000000000000000000000000) >> 30 == 1
- id: sint
type: b1 # equivalent of (inforaw & 0b00100000000000000000000000000000) >> 29 == 1
- id: buul
type: b1 # equivalent of (inforaw & 0b00010000000000000000000000000000) >> 28 == 1
- id: tyle
type: b4 # (inforaw & 0b00001111000000000000000000000000) >> 24
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment