DASYLab

cancel
Showing results for 
Search instead for 
Did you mean: 

Data format for hex answer

Solved!
Go to solution

Hello there,

 

I have issues to create the good data format mask to extract the data received from an RS-232 device.

 

The communication is working fine :

 

Yoruk_0-1607357224420.png

 

But I didn't manage to set up a good format mask.

 

Here is the answer, in hex :

 

01 04 02 00 1B F9 3B

 

I want to keep only the bytes 4 and 5 (in bold in this example). The first 3 ones are header, the two last are CRC, so I can skip them.

 

I tried this :

 

6x 4ah 4x

 

But doesn't works. Maybe because this syntax works only with ascii characters ?

I tried to find a suitable sample in the help, but I didn't find anything.

 

Is there a way to skip bytes ?

 

Thanks in advance !

 

0 Kudos
Message 1 of 6
(4,241 Views)

Ok I tried to use

 

"\x01\x04\x02"2ah

 

as data format mask. Regarding the RS232 monitor my data is correctly detected :

 

Yoruk_0-1607413018153.png

 

So my data (in red) is 0x00 0x1B , which is correct. But why the output is still 0 ?? 

 

0x00 0x1B should be 27 in decimal...???

 

0 Kudos
Message 2 of 6
(4,209 Views)

You need to read the last two bytes, too, to complete analysing the entire message.

 

Instead of '2ah' try 'i' (for signed short int) oder 'w' (word -- unsigned short), or 'iy' / 'wy' (Big-Endian versions).

 

Add another channel, read one 'i' (two byte), but do not connect the output, just read the bytes and ignore the output of the message's last two bytes.

 

 

M.Sc. Holger Wons | measX GmbH&Co. KG, Mönchengladbach, Germany | DASYLab, DIAdem, LabView --- Support, Projects, Training | Platinum NI Alliance Partner | www.measx.com
Message 3 of 6
(4,183 Views)

Many thanks !

 

So I created a second channel, with only "i" as a measurement data format.

 

Going into the RS232 monitor, I now have a value : 😀

Yoruk_0-1607954484409.png

 

But I don't see why the data value is 0.15353E05. My incoming data is "00 1B" in hex so I should have 27 in decimal...?

 

0 Kudos
Message 4 of 6
(4,175 Views)
Solution
Accepted by Yoruk

Because '2ah' ist not correct, use i, w, iy, or wy instead, please.

 

One uses 'ah' as format string if a device sends hex numbers as ASCII text, e.g. 'F1<CR>' (= 241dec).

That would be "46 31 0D" as hex. (ASCII table 'F' = 46h, '1' = 31h, '<CR>'=0Dh).

 

But that is not the case for your example, you can interpret the bytes... "directly".

M.Sc. Holger Wons | measX GmbH&Co. KG, Mönchengladbach, Germany | DASYLab, DIAdem, LabView --- Support, Projects, Training | Platinum NI Alliance Partner | www.measx.com
0 Kudos
Message 5 of 6
(4,168 Views)

Ok I got it !

 

So finally I used

 

"\x01\x04\x02"iy2x

 

And it works directly, even if I don't have anymore the color highlighting :

 

Yoruk_0-1607961511283.png

 

The output value is now ok ! And thanks to the last "2x" in the mask I didn't need a second channel to finish reading the data ! 😀

 

Thanks a lot for your help !

 

0 Kudos
Message 6 of 6
(4,157 Views)