[ANN] intel_hex.0.3

Hi there!

I am excited to announce the release of the intel_hex library. This library is a manipulation library that provides functions for reading, writing, and creating Intel HEX data, which is a common format used in embedded system programming.

Intel_hex.Record.
  [
      Extended_segment_address 0x0F;
      Data (0x0000, "Hello ");
      Data (0x0007, "World!");
      End_of_file;
  ]
|> Intel_hex.records_to_string 
|> print_endline
:02000002000FED
:0600000048656C6C6F20E6
:06000700576F726C6421CA
:00000001FF

Also, you can of course read the IHEX object file from other sources:

In_channel.with_open_text "data.hex" Intel_hex.object_of_channel
- : Intel_hex.Object.t = 
{ 
  start_linear_address = 0;
  start_segment_address = {cs = 0; ip = 0};
  chunks = [(240, "Hello "); (247, "World!")]
}

Limitations

32-bitness. To represent 32-bit integers, the library uses the OCaml int data type. This may be problematic for 32-bit systems, as it can lead to overflow errors, but it works fine for most 64-bit systems.

Start addressing and extending addressing. Not fully supported for real-world use. I would appreciate your pull request on this!

By the way, the optint library provides efficient “at least 32bit integers”, which use int on 64bit machines but Int32.t on 32bit machines.
Although using it will probably also leak into your library interface which might not be worth the hassle for the rare 32bit machine user.

1 Like