I am writing a system to allow remote procedure calls. I want to make sure that it would be platform independent as possible, so that if I pack an integer on a x86-64 machine (4 or 8 bytes), the generated unpacking code on the target, which can be a 8051 (int is 2 bytes) will still be able to correctly handle this. So my issue is that "int" and "long" have different meaning on different platforms. I thought of writing a generic integer packer (and support other types) than accept a void pointer and the width of the data pointed to. It will then call htonl() onto the memory location and copy it to the buffer. The unpacker needs to do the other way around, but I am not entirely sure what to do if the data does not fit the available native type. Any thought will be much appreciated!
The more common approach would probably be to have a command/response protocol - so that microcontroller_1 asks microcontroller_2 to do some specified action; microcontroller_2 does it, and returns the result to microcontroller_1
http://www.keil.com/forum/59411/
But did you use sticky back plastic?
Clearly define the size and endianness of the data structures being passed back an forth. Pick sizes for parameter based on their range, and the desired compactness of the structure. Decide which end need to do the least work, ie do you want a 12 MHz 8051 labouring over work a 3 GHz CPU would laugh at?
Look at how others have solved these types of data passing concepts since the dawn of the digital age.
Thanks. I _insist_ on doing this myself :-)
Ok, not problem with that, just don't patent your solution if it's obvious..