Yo!
I am happy to announce the first major release of the Intel HEX manipulation library.
Intel HEX format is commonly used to represent compiled program code and data that is loaded into a microcontroller, flash memory, or ROM in embedded systems programming.
And now you can work with it in pure OCaml!
Changes
- Redesign API;
- Added
Memorymodule to process memory images of your firmwares; - Instead of using the
ohexpackage, we start use hexen for encoding and decoding hexadecimals;
In use
The library provides a simple API for parsing and creating Intel HEX files. To create an Intel HEX file, you can use the following code:
Intel_hex.Record.
[
Extended_linear_address 0x0F;
Data (0x0000, "Hello ");
Data (0x0007, "World!");
End_of_file;
]
|> Intel_hex.Object.to_string
|> print_endline
:02000004000FEB
:0600000048656C6C6F20E6
:06000700576F726C6421CA
:00000001FF
And to parse a string containing an Intel HEX file:
":0600000048656C6C6F20E6\n:06000700576F726C6421CA"
|> Intel_hex.Object.of_string
(* - : Intel_hex.Object.t =
[ Intel_hex.Record.Data (0, "Hello ");
Intel_hex.Record.Data (7, "World!") ] *)
However, the library also provides a module for working with memory images built from Intel HEX files or other sources.
Intel_hex.Memory.of_string ~block_size:6 "Hello World!"
(* - : Intel_hex.Memory.t =
[ Intel_hex.Memory.Segment(0x0000, "Hello ");
Intel_hex.Memory.Segment(0x0006, "World!") ] *)
For more details, see the API reference.