Page 1 of 1

LOG subsystem and sections

Posted: Thu Apr 23, 2015 12:28 pm
by Nyothan
Hello everyone,

I want to implement the Crazyflie LOG subsystem in ADA. I'm trying to figure out how it works in log.h and log.c.

I see that the macros used to register Log groups with the variables to be logged (LOG_GROUP_START, LOG_GROUP_STOP) puts all the 'log_s' structures (containing the type, the name and the address of the logged variable) in a special binary section.

My question is why you want to put all these structures in a special section instead of defining a function that symply adds a 'log_s' struct into a global array of 'log_s' structs when adding the variables we want to log? Is it necessary to know the exact size and all the variables we want to log at compile time?

I'm not sure to understand the reasons of this choice, but I'm sure that they exist. I just want to know them.

Thank you in advance :)

Re: LOG subsystem and sections

Posted: Thu Apr 23, 2015 2:04 pm
by arnaud
Hi Nyothan,

The reason is precisely to setup the log and param TOC at compile time and not at runtime. It makes it much easier to declare new log and param variable. And the different section is the only way I know to achieve that at compile time.

If it was done at runtime only it would require to declare all log/param variable before an init function and to add them to the toc in init. It would make mandatory to have some kind of an init function for all files that want to benefit from log/param which makes things more complicated. By the way I am planing on doing the same trick for the deck API (a macro that registers a deck driver), this time for modularity reason.

I would assume that this part of the program is very "C-specific" and I do not know if it maps at all to ADA. From the communication point of view it does not matter if the log/param TOCs are built statically or dynamically so you can chose.