Forum

Hexadecimal to Raw

Back in v4 world, I want to first thanks all the dev team for the new great improvment of the beta30.

I’m just lost with Raw data for new RS232 node.

How to convert Hexadecimal command (01 D4 0D FF) to Raw ?

Thanks by advance for your help.

what does your device expect?
four character pairs like ‘0’ ‘1’ - ‘D’ ‘4’ - ‘0’ ‘D’ - ‘F’ ‘F’?
or
four integer values like 01 D4 0D FF or in decimal 001 212 013 255?

in case it expects characters you need to ask yourself in what encoding. if unsure and you’re working with devices go for US-ASCII. given you have that ‘01 D4 0D FF’ string already, just use a AsRaw (String) node before your RS232 (Devices) node, set the encoding accordingly and you’re done. you might get rid of those spaces before though.

in case it expects integer values you’ll first need to convert your string to values - you can use the Ord (String) node for that. those values can afterwards be converted to raw with the AsRaw (Value) node.

see attached patch for an example.

hex_to_taw.v4p (8.3 kB)

Thanks a lot Elias for this precise reply. The device was expecting integer. It works well now !

Hello again,

I was thinking I had understood, but with this new problem I’m still confused.

From my device I received data which are displayed like this at the output of the “AsString(raw)” : 01 00 8E A1 05 5F 00 01 04 E0

First question : As it’s raw, it should be dispalyed as a list of 1 & 0 ? Why it’s already transformed into hexadecimal ?

So I tryed to convert this raw value to an hexadecimal string, I used Byte node, I set the Mode pin to “Hex”, and I obtain :
01 00 7D A1 05 5F 00 01 04 E0

Second question : Why is there a difference ? How to get a string which contain : 01 00 8E A1 05 5F 00 01 04 E0 ?

Thanks again for your precious help.

  1. it’s very common to display a byte as a hexadecimal value because it only needs two digits. would we use a binary representation we’d need 8 digits. but i agree the UI could certainly be improved around the raw datatype.

  2. best you post your patch.

  1. Ok, it’s logic not to display a huge list of 0 & 1.

  2. You will find the patch attached, I didn’t send it at first as you dont have the device to make the test.

test.v4p (11.7 kB)

Testing one by one all the format of the AsString (raw) node, I found that the :
iso-8859-1

was displaying the same value than the one vvvv display at the raw output of the RS232 node. But I really want to know why this one and not another ?

My device is an industrial rfid reader, I dont want a format which works on some tags, and does not on others…

Thanks again for your help

well why even try to interpret the raw data as a string when it actually represents integers?

made a full roundtrip, from hex string to byte and back. see attached patch.

hex_to_taw_roundtrip.v4p (10.7 kB)

Ok yes it’s logic when I see the patch.

I should have think :
I receive a list of integer
An integer is a value so I need to convert raw to value
Finaly convert value to hexadecimal

But with my limited brain I was simply thinking :
I receive raw datas
I want a string in hexadecimal
I need AsString(raw) with the hexadecimal format option… or eventually a byte(raw) node.

It’s probably the difference between a developer and a user :)

Thanks a lot.