Ada codegen from Vector DBC file?


I’m exploring Ada and Spark as an alternative to what is currently a C++ embedded application.
I have a set of DBC files that I currently generate C code from and while it’s possible to still use these C sources, I’m curious if anyone is generating Ada code from DBC files.

Hi @photex and welcome!

I have never heard of DBC files in the embedded world, only SVD files for hardware description… Is there a file format reference? Though from what I know about the Ada landscape, I doubt that there will be a parser/generator program out there :frowning:

Best regards,

DBC files describe how to serialize messages when using a CAN bus.

So to give an example, in this current project the motor controller company provides a DBC file to me which describes what information I can read from the bus, as well as which messages I must send in order to make requests. Same for the steering system and brake system, and so on.

What we’ve done for years now is just generate C code from these and bind them to everything else (Rust, C++, C#, Python).

For people using Simulink usually they can load these DBC files directly and have their models all wired up.

For folks using something like the NVIDIA Drive platform they have a library that’s a bit like an interpreter in C++. You load the DBC at runtime.

There are also some libraries in python to do the same.

1 Like

I see, thank you for your explanation. I saw if Ada4Automation (A4A) had any code generation support for it but it seems it does not… I would bet that there is some close source program out there that probably generates Ada code from the DBC spec, but I don’t think an open implementation exists…

As you point out, you could go with the “binding” technique that you have already used with other languages… Ada is pretty good with regards to C interop. And if you have the C header/body files, you can use GCC’s automatic binding generation in order to automate the process…

I hope this helps. Best,

1 Like

I wonder if something like RecordFlux could be used to mimic the DBC format and then generate the SPARK code from that?


One way that can be explored is to…


I hadn’t seen RecordFlux before, sounds very interesting.

I also never considered taking an existing grammar either. Also intriguing.

Which then reminded me that, we generate C code using a python library, it would be possible to add an Ada generator to this!