bin2header¶
Utilities for generating a “C” header file from binary data
See the source code on Github: yzlite/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)[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 (
Optional[str]) – Output file. Use input with .h appended if omittedvar_name (
str) – Name of C arraylength_var_name (
str) – Name of variable to hold length of C array in bytesattributes (
Optional[str]) – Attributes to prepend C array variabledtype (
str) – The data type of the C arrayprepend_lines (
Optional[List[int]]) – List of C lines of code to prepend before the generated array data e.g.: #include <stdint.h>fmt_str (
Optional[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:
Path to generated C header