Quantcast
Channel: Instrument Control (GPIB, Serial, VISA, IVI) topics
Viewing all articles
Browse latest Browse all 5625

serial reading and converting to HEX for processing data

$
0
0

Hi everybody!

 

I have to read a set of data provided by sensors that communicate via RS232 serial protocol. I've implemented a VI that reads continuosly the string output of the serial port, but I also have to process and analyze data to do other tasks with it. I thinked to use a consumer/producer structure because the reading process is faster than the analysis process.

 

In reading everything is OK, but I've the following problems:

 

1. There are three types of data I've to manage, each one with different length in bytes. I also need to convert them from ASCII to HEX. I do this with the Type Cast tool, but the converted characthers are followed by a big number of zeros before the next valid character.

 

By example, the valid set of data are:
- 24 04 C1 XX (first length)
- 24 09 CB XX XX XX XX XX XX (2nd length)
- 24 12 C9 XX XX XX XX XX XX XX XX XX (3rd length)

 

Instead, I read in the file that is created by the producer loop:
- 2404C1XX00000000000000002404C1XX00000000000000000000000000000000000000000000000...00000002409CBXXXXXXXXXXXX000000

 

2. First three bytes of each type are respectively the START of FRAME, LENGTH of FRAME, TYPE of DATA HEX codes. The VI has to be able to recognize the first one to split the whole set of data in small parts for being processed
in the right way.

 

Does someone have any idea?

 

I've attached a screenshot of my first attemp to to this.


Viewing all articles
Browse latest Browse all 5625

Trending Articles