↓Skip to main content

Talking to the DM16L, and sending a dump

The last and final part is dm_send, which can send the downloaded memory dump again. I thought it would be quick as I had prepared everything already. AdaCL.Serial offered everything I needed. Famous last words. I was of course wrong. GNAT.Serial_Communications broke on Ubuntu 26.04 — oh dear. Great.

Linux baud rates on newer glibc #

Like macOS, Linux communication also needed a library fix. Newer glibc (2.42 and later, as on Ubuntu 26.04) redefined the baud-rate constants. B57600 used to be the old token 4097. It is now the numeric rate 57600. GNAT.Serial_Communications still embeds the old values from the headers that were current when the compiler was built. Passing the old token sets the wrong speed.

The official GCC fix will take time to reach a release I can depend on. AdaCL.Serial 8.3 does the regeneration at build time instead. On Linux it reads the host headers and the GNAT sources, then produces the constants and the body that match the running glibc. The same binary that talks to the DM16L on an older distribution continues to talk on a newer one. No local rebuild of the runtime is required.

For this I now generate AdaCL.Serial_Communications from the GNAT.Serial_Communications source using AdaCL.SAR (SAR stands for Search and Replace). This is what AdaCL.SAR was built for: full text conversion. The text can be a vector of unbounded strings, a text file or a standard input ⇒ output pipe. I now do this both for Linux and macOS.

SAR is quite powerful and has a few features that are quite difficult to achieve with simple regular expressions, like inserting lines while copying pre- and postfixes from the matched line. This can be used to properly indent the new line or properly match the ASCII-art box of a copyright statement.

The Indefinite_Vectors bug #

I spent more time than I wanted on a bug in Ada.Containers.Indefinite_Vectors. The dump is a sequence of indefinite strings. Building a vector of them, then letting the vector go out of scope, triggered a finalisation problem that only showed up on the way out.

AdaCL.Trace is the tool I reach for when something dies in Finalize. The trace log showed where the problematic variable was finalised. Once I could see the sequence, the fix or better workaround was straightforward: Just read the file one line at a time without buffering in a vector. From the performance it should make no difference.

Where the rest of the bench is #

The workshop door is Swiss Micros Tools. The clock dialogue is the dm_set_time packages. The receive path is Talking to the DM16L, and receiving a memory dump. Generated reference is GNATdoc. Sources are on the master branch.

Both directions are now finished. I can pull a memory dump and push one back without opening a terminal.