Protocol
<STX>COMMAND<ETX><CHEKSUM>
a valid command is:
.004CT1000A.b
with STX = 0x02, ETX = 0x03, CHECKSUM = 0x0062, COMMAND = 004CT1000A
I want to send this command with powershell on a windows server to a serial port. However there are data type issues:
PS > [Char[]] $request = 0x02,0,0,4,"C","T",1,0,0,0,"A",0x03,0x0062
PS > $port.Write($request)
This logs a strange string with whitespace on the left and right of each character:
. . . . C T . . . . A . b
instead of
.004CT1000A.b
Any ideas what I am doing wrong?
and I tried
PS > [Char[]] $request = 0x02,"0","0","4","C","T","1","0","0","0","A",0x03,0x0062
PS > $port.Write($request)
which printed the right command but with a lot of whitespaces
. 0 0 4 C T 1 0 0 0 A . b
.004CT1000A.b is created with:
unsigned char checksum = 0x02;
nrComm1->SendChar(0x02);
while(*TX_String)
{
nrComm1->SendChar(*TX_String);
checksum ^= *TX_String++;
}
nrComm1->SendChar(0x03);
checksum ^= 0x03;
nrComm1->SendChar(checksum);