LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending ASCII character codes to serial port

Hello,

I have a remote controlled relay that takes commands via a serial port. It takes commands in ASCII character codes, 1 meaning turn on relay for instance. My problem is that when you send a 1 to the serial port, it gets interpreted as the ascii character 1, ans sends the code for 1 instead (49).

Does anyone have a good solution for this?

Thanks,
Mathias
0 Kudos
Message 1 of 6
(6,024 Views)
Hi Mathias,
right click on the string constant you are sending to the serial port, check "Hex display", then input any numerical value you want (in hex form, of course)
Paolo
-------------------
LV 7.1, 2011, 2017, 2019
0 Kudos
Message 2 of 6
(6,013 Views)
I'm not sure if this will solve your problem but you could try to use the Byte Array To String and the String to Byte Array functions. In LV8.2.1, there are located in the String >> String/Array/Path Conversion group of the functions palette.



See the context help for more details.

Message Edité par JB le 05-10-2007 10:37 AM

0 Kudos
Message 3 of 6
(6,011 Views)
Thanks for your quick replies,

I looked at the 'byte to string' earlier but did not quite understand how it worked. Is it so that the string then will contain the ascii characters that in the end will be transformed to the correct ascii character code?

0 Kudos
Message 4 of 6
(6,003 Views)
Exactly. JB's suggestion may be very useful especially when the command contains variable parameters and must be dynamically built.
Paolo
-------------------
LV 7.1, 2011, 2017, 2019
0 Kudos
Message 5 of 6
(5,994 Views)
Ok, I got it to work. Thanks guys!
0 Kudos
Message 6 of 6
(5,989 Views)