mltk.utils.bin2header¶
Utilities for generating a “C” header file from binary data
See the source code on Github: mltk/utils/bin2header.py
Functions
|
Generate C header file from binary input file |
|
- bin2header(input, output_path=None, var_name='DATA', length_var_name='DATA_LENGTH', dtype='const unsigned char', attributes=None, prepend_lines=None, fmt_str=None, prepend_header=True)[source]¶
Generate C header file from binary input file
- Parameters:
input (
Union
[str
,bytes
,List
[int
],List
[float
]]) – Either path to binary file or binary contents of previously loaded file, or list of integers or floatsoutput_path (
Union
[bool
,str
,IOBase
]) – Output file path or io stream. Use input with .h appended if Truevar_name (
str
) – Name of C arraylength_var_name (
str
) – Name of variable to hold length of C array in bytesattributes (
str
) – Attributes to prepend C array variabledtype (
str
) – The data type of the C arrayprepend_lines (
List
[int
]) – List of C lines of code to prepend before the generated array data e.g.: #include <stdint.h>fmt_str (
str
) – The formatting string to use for each entry in the data, e.g.: 0x{:02X} If omitted then it is automatically determined based on the given data
- Return type:
str
- Returns:
Generated header as a string