Home > Back-end > MSComm control an InputMode problems
MSComm control an InputMode problems
Time:09-29
When doing a serial port programming, using MSComm control, binary mode and concrete difference in text mode? Can you explain with an example
CodePudding user response:
An InputMode attribute: serial port to receive the data mode, comInputModeText (0) in text (ASCII) way to retrieve data, ComInputModeBinary (1) said in a binary way to retrieve data ComInputModeText comInputModeBinary for predefined constants, respectively 0, 1
CodePudding user response:
Text
Void __fastcall TForm1: : MSComm1Comm (TObject * Sender) { AnsiString STR.//declare an AnsiString variables of type OleVariant s;//declare an OleVariant variables used to receive data, If (MSComm1 - & gt; CommEvent==comEvReceive)//in the receive buffer if received Rthreshold characters, { If (MSComm1 - & gt; InBufferCount)//if there is a character resides in the receive buffer waiting to be remove { S=MSComm1 - & gt; The Input;//receiving data STR=s.A sType (varString); //OleVariant variables into it receives AnsiString type Memo1 - & gt; Text=Memo1 - & gt; The Text + STR;//to display the data received in Memo1, } } }
CodePudding user response:
The following two seemingly binary is byte type, the need to deal with conversion data type
http://zhidao.baidu.com/link? Url=1 kzbw1ffewptfvzkgwp3zlhzju6r6haux9dwxaunre3cca2xcxns2u9fwvxmawyesvfdyio7lk5upuehuccbzvsz6ta10wqmrcxsbvzz - 3 I