LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

decode strange character when recieved data from RS232 port

Hi Vicky,

0x(arr[1]) is not legal in C, hence you get a compile error.
If your arr[] is already in hex but the elements don't start with "0x", you could convert these elements to hex and then use AI S's suggestions. For instance:

char myHex[100];
int result;

sprintf (myHex, "%d", arr[0]);
result = htoi(myHex);
printf("ASCII %#x = \"%c\"\n", result, result);

You can find implementations for htoi (which converts a hex string to its equivalent int value) on the internet (here is a link to one implementation).

Note, this might not be an efficient way of doing this since it involves hex conversions back and forth, but it should get you started.

Good luck!
Shakhina P.
NI
0 Kudos
Message 11 of 11
(1,085 Views)