LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to send a Hex format command to RS232 port using LabWindows CVI?

I want to ask you ,how to send Hex command to RS232, For example, i need send 5401499CFF00 as hex To RS232,now i just use ComWrt(1,"5401499CFF00",strlen("5401499CFF00"));
but you know it is not my meaning,could you tell me how to do?
 
thank you for your help.
 
0 Kudos
Message 1 of 3
(5,324 Views)
You want to send 0x5401499CFF00, which is a 6-byte hexidecimal number.  This is very different than "5401499CFF00", which is a 13-byte (including nul terminator) ASCII string.  Try something like this:

char message[6];

message[0] = 0x54;

message[1] = 0x01;

message[2] = 0x49;

message[3] = 0x9C;

message[4] = 0xFF;

message[5] = 0x00;

ComWrt(1, message, 6);

Also note that if you do want to send a string in the future, you should specify the size as strlen(yourstring) + 1, just as you would if using a memory copy function. ComWrt and the rest of the serial library functions operate on data as raw bytes; they don't assume the data are nul-terminated strings, so if you want to send the nul terminator (which you do), you have to explicitly include it in the count.

Hope this helps.

Mert A.
National Instruments

Message Edited by Mert A. on 09-27-2007 10:10 AM

Message Edited by Mert A. on 09-27-2007 10:15 AM

0 Kudos
Message 2 of 3
(5,314 Views)
Thank you ,with your help, i get it
0 Kudos
Message 3 of 3
(5,294 Views)