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

http://blog.hehehehehe.cn/a/16082.htm

CodePudding user response:

reference ksrsoft reply: 3/f
the following two seemingly binary, is byte type, the need to deal with the conversion data type

http://zhidao.baidu.com/link? Url=1 kzbw1ffewptfvzkgwp3zlhzju6r6haux9dwxaunre3cca2xcxns2u9fwvxmawyesvfdyio7lk5upuehuccbzvsz6ta10wqmrcxsbvzz - 3 I

http://blog.hehehehehe.cn/a/16082.htm


At the time of processing encountered a little problem:

In binary mode can be accept by OleVariant variables and parse the data, but only by what you said in the text mode, casts into AnsiString, receive by OleVariant variables which would be an error in reading elements number, and then analyzed the type of the two modes of OleVariant, found that binary VT_BYTE, text is VT_OleStr,

But only enter the binary and text mode transmission seems to deal with in a different way?

CodePudding user response:

The binary and text mode of transmission of the data interpretation is different,

CodePudding user response:

reference 5 floor songhtao reply:
binary and text mode of transmission of the data interpretation is different,
please explain

CodePudding user response:

http://www.doc88.com/p-4995455257208.html

CodePudding user response:

The book needed?
"C + + Builder and the RS - 232 serial communication control" fan tat of tsinghua university press
https://2.taobao.com/item.htm? Id=521946220490 & amp; SPM=686.1000925.0.0 tWaCyI

CodePudding user response:

Example for not to come out, care about other people's examples?
  • Related