I have created a function that packs the data down from 40 sensors in to a binary representation.
The representation can be 4, 7, 8 or 16 bits.
there is a 3bit prefix attached to the result so each reading form the sensor ends up something like..
001 1101 = sensor value of -13.
010 1011110 = sensor value of +94
100 10110101 = sensor value of +181
111 1011101011011010 = sensor value of -47834
110 1011101011011010 = sensor value of +47834
These "bytes" are all stuffed in to a string and tailed on to each other the application at the receiving end looks at the first 3 bits and extracts the data in the correct manner.
Since I have 40 sensors the values transmitted are only the delta from the first sensor in the chain so mangling the binary data in this way reduces the size of the sent packet really well as the transmission system I am using (Iridium Sat Link) charges per 50Bytes of data so the smaller i get this the better.
Using this process the average packet ends up being about 47 to 48 bytes.
Now the part I am having issues with and partly due to my lack of skill. I have had to assemble the final packet as a string to ensure that all the pseudo bytes are not signed.
I am trying to work out how to convert the String back to binary format as the Modem requires the data to be sent in binary format. If i try and pipe the string to the modem it treats is as text.
Has anyone got any suggestions as to how best to do this?
Regards
Boris