Support Forums
Translate Hex code to ASCII

Hi,

I am receiving Hex data (53 4E 4D 31 32 30 31 36 37 39 45) via a RS232 connection, how can I translate this to readable ASCII?

Regards,
Friedrich

Hi, I am receiving Hex data (53 4E 4D 31 32 30 31 36 37 39 45) via a RS232 connection, how can I translate this to readable ASCII? Regards, Friedrich

I don't understand if your receiving software is not converting the received data to Ascii or if you need a "una tantum" conversion; In this case your string is SNM1201679E (reference http://www.asciitable.com )

I don't understand if your receiving software is not converting the received data to Ascii or if you need a "una tantum" conversion; In this case your string is SNM1201679E (reference http://www.asciitable.com )

Hi Teo,

I want to do this translation 'on the fly' in the software.

Regards,
Friedrich

Hi Teo, I want to do this translation 'on the fly' in the software. Regards, Friedrich

This section suggests that you are using dEX, but via RS232 is quite unusual... Could you please post more details concerning your system setup?

This section suggests that you are using dEX, but via RS232 is quite unusual... Could you please post more details concerning your system setup?

I am using the dEX software to program the DT85 (via USB).

The sensor port is used to communicate to a controller. The controller returns hex code in ASCII format. Instead of "S" "53" is send. I want to translate the hex code into readable ASCII in the program.

Regards,
Friedrich

I am using the dEX software to program the DT85 (via USB). The sensor port is used to communicate to a controller. The controller returns hex code in ASCII format. Instead of "S" "53" is send. I want to translate the hex code into readable ASCII in the program. Regards, Friedrich

Ok, clear.
The logger should do the conversion automatically, you have to specify the right format i.e. string data type and put the reading in a text channel (e.g. 1$). Give a look at the user manual (release UM-0085-B7) at the top of page 336, the example may clarify better how to proceed.

Ok, clear. The logger should do the conversion automatically, you have to specify the right format i.e. string data type and put the reading in a text channel (e.g. 1$). Give a look at the user manual (release UM-0085-B7) at the top of page 336, the example may clarify better how to proceed.

Good morning Friedrich,

Teo is quite correct, there is no conversion needed, simply read the data as a string.
Try reading the line as a string e.g.
1SERIAL("%s" )

And see if you get the correct response.

Cheers

Roger

Good morning Friedrich, Teo is quite correct, there is no conversion needed, simply read the data as a string. Try reading the line as a string e.g. 1SERIAL("%s" ) And see if you get the correct response. Cheers Roger

Hi Roger and Teo,

This is the log of the DT85:

DT85>
DT85> /h/E/M/R
DT85> 1SERIAL("\e{:06040400210060^M^J}%13s[1$]%2x[2CV]%s[2$]" )
1SERIAL: RxBuf=2[\013\010]
1SERIAL: InputAction: "\e"
1SERIAL: RxBuf-0[]
1SERIAL: OutputActions: ":06040400210060^M^J"
1SERIAL: Tx [:06040400210060\013\010]
1SERIAL: InputAction: "%13s[1$]"
1SERIAL: RxBuf+41[:12040200210007534E4D313230313637394500\013\010]
1SERIAL: RxBuf-28[07534E4D313230313637394500\013\010]
1SERIAL: InputAction: "%2x[2CV]"
1SERIAL: RxBuf-26[534E4D313230313637394500\013\010]
1SERIAL: InputAction: "%s[2$]"
1SERIAL: RxBuf-2[\013\010]
1SERIAL 0 State

DT85> 2$("ID" )
ID 534E4D313230313637394500

DT85>

So 2$ containes the string but this is Hex code.

Regards,
Friedrich

Hi Roger and Teo, This is the log of the DT85: DT85> DT85> /h/E/M/R DT85> 1SERIAL("\e{:06040400210060^M^J}%13s[1$]%2x[2CV]%s[2$]" ) 1SERIAL: RxBuf=2[\013\010] 1SERIAL: InputAction: "\e" 1SERIAL: RxBuf-0[] 1SERIAL: OutputActions: ":06040400210060^M^J" 1SERIAL: Tx [:06040400210060\013\010] 1SERIAL: InputAction: "%13s[1$]" 1SERIAL: RxBuf+41[:12040200210007534E4D313230313637394500\013\010] 1SERIAL: RxBuf-28[07534E4D313230313637394500\013\010] 1SERIAL: InputAction: "%2x[2CV]" 1SERIAL: RxBuf-26[534E4D313230313637394500\013\010] 1SERIAL: InputAction: "%s[2$]" 1SERIAL: RxBuf-2[\013\010] 1SERIAL 0 State DT85> 2$("ID" ) ID 534E4D313230313637394500 DT85> So 2$ containes the string but this is Hex code. Regards, Friedrich

So, seems that your device is returning the Hex code in Ascii characters :?
Maybe a stupid question, could you change the device output format? If not, since I don't know any specific function to do the conversion in DT8x programming languange I can only image a huge work and a very big number of commands to do a manual conversion. But lets wait for others comments...

P.S. What is the serial device that works this way?

So, seems that your device is returning the Hex code in Ascii characters :? Maybe a stupid question, could you change the device output format? If not, since I don't know any specific function to do the conversion in DT8x programming languange I can only image a huge work and a very big number of commands to do a manual conversion. But lets wait for others comments... P.S. What is the serial device that works this way?

Hi Teo,

I can't change the output format in the controller.

The controller has a flowbus interface to communicate with massflowmeters (controllers). This is a specific protocol used by Bronkhorst High-Tech.

regards,
Friedrich

Hi Teo, I can't change the output format in the controller. The controller has a flowbus interface to communicate with massflowmeters (controllers). This is a specific protocol used by Bronkhorst High-Tech. regards, Friedrich
50
10
4
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft