-
How to transmit Data
I want to implement a technique where i want to transmit all the data of a structure. The structure as per the requirement it may change as it is used for testing purpose. For example today i may want to transmit data1, data2 to external interface
Code:
struct data_tag
{
double data1;
double data2;
}data;
tomorrow someone else wants to transmit some other test data he can add another variable where i am not aware of which data type he will use. Another limitation is he can transmit only 8 bytes at a time, next call he has to start from where he stopped. Is it possible to do this? He will use an interface function to transmit data with a pointer to the structure. I am free in choosing the type of structure. please suggest.
-
If your users are responsible for serialising and deserialising their own data, then it's easy for you.
Whether they output
"data1=1.234, data2=4.567"
or
<element name="data1" type="double" value="1.234"/>
<element name="data2" type="double" value="4.567"/>
is not your concern.
All you have to do is achieve a reliable transport.
> Another limitation is he can transmit only 8 bytes at a time, next call he has to start from where he stopped. Is it possible to do this?
Yes, it's a loop.
Code:
void sendData ( void *addr, size_t len ) {
// split len up into 8-byte blocks and send them one at a time over your
// restricted interface.
}