April 10th, 2013, 12:06 PM
"Creating variable" on runtime? - message decoding
here is my problem description:
I receive messages over a bus. Suppose there is a function to read the messages storing them into a struct defined as follows:
Depending on the message ID different messages represent different values for one project.
For example msg with ID 10 can include in the 8 bytes something like:
width: 6 bits
height: 6 bits
actpos: 12 bits
maxpos: 12 bits
minpos: 12 bits
range: 16 bits
total: 64 bits = 8 bytes
Printing the message is no big deal. But here comes the tricky part. I want to print out the specific information hidden in the 8 bytes. I can define the structures for every msg ID and compile the program with this "special" header file, but I want to do it during runtime of the program, loading the information regarding the msgs, because i can have different projects where the information for different msg IDs can differ.
I've a non-C file, where basically all the information is written. Lets stay frame named
bit 0 - 7 width
bit 8 - 15 height
How to read it on runtime and decode the messages? On runtime I'm not able to create variables and structures anymore!
Any advices? Is some sort of scripting language the solution? Which, how? :-)
Thanks in advance for all replays!
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.