 |
 |
| View previous topic :: View next topic |
| Author |
Message |
newguy
Joined: 24 Jun 2004 Posts: 1934
|
|
Posted: Mon Aug 10, 2015 8:57 pm |
|
|
| lucasromeiro wrote: |
However what I did not understand is the step by step how to make a package, for example this:
@0999;100;25/10/15-23:22:34;4294967290;500;0;15555;72;4294967290;9;50; |
There's really nothing to understand. Your whole data packet can be broken into 11 x int32, or 44 bytes. I'm just counting your 11 data fields and assuming that you'll require an int32 for each. If you do not require 4 bytes per field, then you can obviously save data on the fields that can make do with less than 4 bytes.
For example, your date can be expressed as an int32. Just google "seconds since epoch" or "unix time". That's 4 bytes to express the date and time to the second instead of the 17 characters/bytes you've shown above.
On the receiving end, you just recombine the bytes into int32's or int16's or whatever you encoded on the transmitting side.
Here's your packet broken into raw bytes, assuming int32 (4 bytes per field):
0999 : 000003E7
100 : 00000064
25/10/15-23:22:34 : 5620353A
4294967290 : FFFFFFFA
500 : 000001F4
0 : 00000000
15555 : 00003CC3
72 : 00000048
4294967290: FFFFFFFA
9: 00000009
50: 00000032
That's it. Just string together the raw bytes. On the receiving end you know that bytes 9-12 inclusive are your time/date. Similarly, you can denote other bytes as belonging to other data fields.
One caution: add a data format field. Call this layout above v1.0. Put that format into the data stream somewhere. That way when you inevitably improve this format or your boss asks you to alter it or a customer asks for an additional piece of information, putting new hardware into the field won't break whatever is listening for these reports. |
|
 |
lucasromeiro
Joined: 27 Mar 2010 Posts: 167
|
|
Posted: Mon Aug 10, 2015 9:36 pm |
|
|
| newguy wrote: | | lucasromeiro wrote: |
However what I did not understand is the step by step how to make a package, for example this:
@0999;100;25/10/15-23:22:34;4294967290;500;0;15555;72;4294967290;9;50; |
There's really nothing to understand. Your whole data packet can be broken into 11 x int32, or 44 bytes. I'm just counting your 11 data fields and assuming that you'll require an int32 for each. If you do not require 4 bytes per field, then you can obviously save data on the fields that can make do with less than 4 bytes.
For example, your date can be expressed as an int32. Just google "seconds since epoch" or "unix time". That's 4 bytes to express the date and time to the second instead of the 17 characters/bytes you've shown above.
On the receiving end, you just recombine the bytes into int32's or int16's or whatever you encoded on the transmitting side.
Here's your packet broken into raw bytes, assuming int32 (4 bytes per field):
0999 : 000003E7
100 : 00000064
25/10/15-23:22:34 : 5620353A
4294967290 : FFFFFFFA
500 : 000001F4
0 : 00000000
15555 : 00003CC3
72 : 00000048
4294967290: FFFFFFFA
9: 00000009
50: 00000032
That's it. Just string together the raw bytes. On the receiving end you know that bytes 9-12 inclusive are your time/date. Similarly, you can denote other bytes as belonging to other data fields.
One caution: add a data format field. Call this layout above v1.0. Put that format into the data stream somewhere. That way when you inevitably improve this format or your boss asks you to alter it or a customer asks for an additional piece of information, putting new hardware into the field won't break whatever is listening for these reports. |
PERFECT !!
Thanks for the tips, I am documenting everything.
Got it, I was thinking that I would need to "convert" also markers .... I thought I would make the string sending and convert it all.
So if the data were transformed into HEX, right?
would difference if binary?
in this case I would only need to concatenate a string and send it?
gather all this data with markers and concatenate (strcat) in a single string and send the data ??
one more doubt, is to further improve utilization of this data? or compress. |
|
 |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue Aug 11, 2015 5:07 pm |
|
|
ok so you are talking about cell phone users of the data?
who is going to write the APP that decodes your "compressed" data for the end user? |
|
 |
lucasromeiro
Joined: 27 Mar 2010 Posts: 167
|
|
Posted: Tue Aug 11, 2015 6:53 pm |
|
|
| asmboy wrote: | ok so you are talking about cell phone users of the data?
who is going to write the APP that decodes your "compressed" data for the end user? |
no, no....
I have a board with a PIC that collects data from sensors and sends it to my server.
(Telemetry)
Can you help me understand what our friends tried to explain me? |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20061
|
|
Posted: Wed Aug 12, 2015 1:22 am |
|
|
I think you need to go away, and do some very basic reading on data transmission.
Data is sent normally as 'lumps' referred to as bytes. 8 binary digits. Not always - some systems use 7, some use 9, and historically there were even coding's that used 5. The hardware does the job of sending this byte 'bit by bit', and adding the synchronisation bits.
Now you can use such a lump in a lot of ways.
You have a number stored in your computer. 120000 say. This 'requires' seventeen bits to store (2^17 = 131072). It could be sent over an 8 bit transmission medium therefore as 3 bytes (24 bits), or sent as text (ASCII) - 6 bytes, or sent as ASCII hex (6 bytes), or sent as binary (17 bytes). All equally easy to do, all transferring the same data, but all having different advantages/disadvantages.
The text form's only real advantage, is that it is human readable. Downside is that it only uses just over three bits out of every eight, to actually transfer useful data. Hex retains some degree of human readability and increases this to four bits our of eight (there is a slight saving for larger numbers 4000000000 for example uses just eight hex digits). However not a lot better. Binary would not normally be used for transmission over an 8bit link.
The point is though, that if you send the raw data stored in your computer, as bytes, this makes the best use of the transmission medium. Then there are ways of making even bigger improvements by thinking in computer terms rather than human. The clock is a classic example. The human form has separate hours, minutes, seconds, day of month, month of year, and year counters. Fourteen characters plus separators. A single 'seconds since midnight year 2000' counter, instead allows any time for over a century to be sent as just four bytes. Then if (for instance) a number only goes up to 9999, there are potentially 2 bits still 'left' out of a pair of bytes. If other things have to be sent like a status flag for what the instrument is doing, then this could potentially use these spare bits.
Now the downside of packing data really tightly comes when something goes wrong. A 'number' based text transmission, may still receive a legitimate number if a bit is damaged, but may well not. You have a high probability of being able to detect that something has gone wrong by receiving a non numeric result. With a form that sends everything packed tightly every possible value is used in the bytes, and you cannot detect an error. So the solution then is to add a CRC. This 'wastes' a byte (or more), but gives an increasing chance of detecting an error, and rejecting the packet.
The the very nature of your data may allow for less to be sent, So (for instance) if values generally ramp slowly, instead of sending the int32 'value' each time, you could send just an int8 'delta' . This limits how fast the data can change, but reduces the transmission space needed to just 1/4, for this particular value. Even better you could use a 'variable slope' form of this. However this all depends on the actual nature of your data.
Your original request for 'compression', shows significant ignorance. Except for making efficient use of the bytes, no compression is really possible on small amounts of data. Where compression starts to work, is where there is a huge amount of data, and some of it, by it's nature 'repeats'. It then becomes possible to to not send the repeated parts. I can't think of any compression algorithm that would actually reduce such a small amount of data. Most would actually make it larger..... |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|