formaty/formats/example.toml

51 lines
1.4 KiB
TOML

# Example fields to show off configuration
#
# Example data:
# "[0x00, 0x55, 0xff, 0x43, 0xd2 0x99 0x90, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x00, 0x57, 0x6f, 0x72, 0x6c, 0x64]"
#
# Example Output:
# int field: 85
# uint field: 0xf
# uint field: 0xf
# float field: 421.1997
# string field: [72, 101, 108, 108, 111]
# bytes field: [87, 111, 114, 108, 100]
[[formats]]
# Format name
name = "example"
# Global bit flip
bit_flip = false
# signed int field, big endian
[[formats.fields]]
name = "int field"
field_type = {type = "Int", bit_width = 16, endianness = "BigEndian"}
# unsigned int field, little endian. also is printed as hex
[[formats.fields]]
name = "uint field"
print_type = {print = "Base", base=16}
field_type = {type = "UInt", bit_width = 4, endianness = "LittleEndian"}
# unsigned int field, little endian. also is printed as hex
[[formats.fields]]
name = "uint field"
print_type = {print = "Base", base=16}
field_type = {type = "UInt", bit_width = 4, endianness = "LittleEndian"}
# single precesion float field.
[[formats.fields]]
name = "float field"
bit_flip = false
field_type = {type = "Float", endianness = "BigEndian"}
# string field. Printed as a byte array
[[formats.fields]]
name = "string field"
field_type = {type = "String", endianness = "BigEndian", max_len = 55}
# byte field
[[formats.fields]]
name = "bytes field"
field_type = {type = "Bytes", endianness = "BigEndian", max_len = 55}