I am working on an embedded system that has different output options (digital output, serial, analog, etc.). I am trying to find a clean way to pass many variables that will control these functions.
I don’t need to transmit them too often, but I was hoping to get a function that will read the input data (in this case from the TCP network) and then analyze the data (IE, the 3rd byte contains states of 8 digital outputs (according to which the bit in this byte is high or low)) and puts it in a variable where I can then use it elsewhere in the program.
I wanted this function to be separated from the main () function, but for this it would be necessary to pass pointers to about 20 or so variables to which he wrote. I know that I can make variables global, but I'm trying to make it easier to debug by making it obvious when functions are allowed to edit this variable by passing it to the function.
My best idea was a structure and just passed a pointer to it, but was not sure if there was a more efficient way, especially since there is only one function that would have to access all of them at once, while most others only part of the information that will be stored in this group of state variables is required.
Anyway, is there a clean way to send many variables between functions at once that need to be edited?
source
share