Home > Back-end >  More than 128 MSComm control solution
More than 128 MSComm control solution

Time:10-27

I want to send data using MSComm control, serial port assistant receives and displays hexadecimal, but more than 128, are shown to 00, the char type serial assistants show after other data types are ASCII, what method can be sent in the past more than 128 values, to hexadecimal display in the serial assistants,
,

////////////////////////////////////////

Char FS [30].
AnsiString Fa [30].

////////////////////////////////////////

FS [0]=0 x81;//beyond 128, shows 00
FS [1]=0 x01;
FS [2]=0 x11;

////////////////////////////////////////

Comm8 - & gt; CommPort=8;
Comm8 - & gt; An InputMode=comInputModeBinary;
Comm8 - & gt; Settings="9600, N, 8, 1";
Comm8 - & gt; PortOpen=true;

////////////////////////////////////////

for(int i=0; i<11. I++)
{

Fa [I]=FS [I];
Comm8 - & gt; The Output=Fa [I];

}
Comm8 - & gt; PortOpen=false;

CodePudding user response:

Use unsigned char, do not use char

Char FS [30].
To:
Byte FS [30].

CodePudding user response:

Demon elder brother:

Unsinged char FS [30].
AnsiString Fa [30].

FS [0]=0 x81;//beyond 128, shows 00
FS [1]=0 x01;
FS [2]=0 x11;



After change the char types to unsigned char types;

Serial assistants hexadecimal display "31 32 39 31 and 37",

Serial assistants ACSII shows "129117",

, according to data using a serial port assistant to send the past don't do other processing, just want to on the serial port assistant hexadecimal receive hexadecimal data!
  • Related