I have a device witch use binary format style config, and i have to generate that files on-the-fly.
File structure must consist of a number of configuration settings (1 per parameter) each of the form:
- Type
- Length
- Value
where:
- Type: is a single-octet identifier which defines the parameter
- Length: is a single octet containing the length of the value field in octets (not including type and length fields)
- Value: is from one to 254 octets containing the specific value for the parameter
I have a corresponding table
Type_code[int] => { Type_length[int] => Value[int/string/hex/etc.] }
How to parse that table to that binary format? And, second way, how to parse that binary file, to php array format back?