10-06-2011 09:04 AM
I have raw binary data coming into a UDP port, from which I want to read 32 bits at a time from the actual production data. Each 32 bits will be of a different format ie 1st 32 bytes - float, 2nd 32 bytes - double precision integer etc... so I need to decode each 32 bytes in a different way. How do I separate my data stream so I can deal with 32bits at a time?
Cheers
10-06-2011 10:15 AM
32 bits is equal to 4 bytes. So you just have to read 4 bytes at a time. Then what you do is use whatever typecast you need to convert it to different data types such as float, integer, etc.
10-06-2011 10:42 AM
If your data will be arriving very quickly you may want to have a separate process which does nothing more than read the data in larger chunks. This process will post the data to another process which will then process the data. In very high speed data streams it is sometimes important to read data as fast as possible to avoid any type of buffer overruns. Processing while reading can possibly slow the reading down too much. Processing in a separate task will alleviate this.
10-18-2011 07:18 AM
How do I create this separate process? I am receiving data at 100 Hz and it seems my program cannot handle this speed as the timing starts to inherit errors.
10-18-2011 08:16 AM - edited 10-18-2011 08:24 AM
Look at the programming constructs such as:
Application Design Patterns: Producer/Consumer
Application Design Patterns: Master/Slave