04-21-2006 02:45 AM
04-21-2006 02:49 AM
Hello Jacky,
you should just use the formatting function: Fmt (a, "3A446B33"). It's in the Formatting and IO Library.
04-21-2006 03:08 AM
I suggest you use this lines of code to correctly decode your original string (in hex format, I suppose) into an unsigned integer array: the format function is scanned two digits at a time, interpreted as an hex value and transferred into the unsinged int array elements. This code can be directly pasted into the interactive window and tested.
#include <formatio.h>
#include <ansi_c.h>
static char a[64];
static int i;
static unsigned int ui[10];
strcpy (a, "3A446B33");
for (i = 0; i < strlen(a) / 2; i++) {
Scan (a, "%s[i*w2]>%i[r16]", i * 2, &ui[i]);
}
04-21-2006 12:31 PM
Thanks, but if I change the data type of ui to unsinged char, how can I get the same function? because I will make ui as the input parameter of ComWrt (selCOM,ui,i).
Another question is about parameter pass in Teststand to a DLL module. I built a DLL with the output function of Message_Send_Read, see below.
int DLLEXPORT Message_Send_Read(unsigned char Tx_Msg[1000], int delay_time,unsigned char Rx_Msg[1000])
{.....
ComWrt (selCOM,Tx_Msg,i+3);
......
ComRd (selCOM, Rx_Msg, buffer_length);
......
}
.When it is called by Teststand, which kind of values should I pass to Tx_Msg and Rx_Msg. I'm sure I can use the data type of arrary of numbers (unsinged 8-bit integer), but not sure whether I can use the data type of String (C String Buffer), like char[1024]?
Thanks for your help.
04-21-2006 01:52 PM
To format into an unsigend char simply change the Scan instruction this way:
static unsigned char uch[10];
Scan (a, "%s[i*w2]>%i[r16]", i * 2, (int *)(uch + i));