Home > Back-end >  C CISerialPort serial port to receive the string garbled
C CISerialPort serial port to receive the string garbled

Time:09-20

MFC to do upper machine, communicate with the board, a serial port Settings: no problem,

Processes are PC issued instructions, the board return a string (only English letters and Numbers), the question now is sometimes received garbled, messy, sometimes Numbers into letters, sometimes become at sixes and sevens in Chinese digital, probably 200 times appeared once,

You see what reason?

Receive data part code:

The static UINT m_nReceiveBytes=0;//this variable is used to receive the character count
Cstrings m_strReceive;

LRESULT CCchipPrintToolDlg: : OnReceiveChar (WPARAM ch, LPARAM LPARAM)
{
M_nReceiveBytes + +;
Cstrings strDis="";
Cstrings strTemp;

StrTemp. The Format (" % c ", ch);
M_strReceive +=strTemp;
The LOG (m_strReceive);
}

CodePudding user response:

Whether to send and receive the binary as well

CodePudding user response:

reference 1st floor a1007885391 response:
is the binary transceiver oh

Transceiver is a string!

CodePudding user response:

refer to the second floor tanzugan response:
Quote: refer to 1st floor a1007885391 response:

Transceiver is binary oh

Transceiver is a string!

Is just A display form A binary string, such as 0 x41 said in characters' A ', said 65 in number;
You can surf the Internet to find a caught tools have a look, if to send and receive data, that is the middle of the data processing should be way out of the question, the size of the client or byte code, etc

CodePudding user response:

According to my log, I receive the character itself is gibberish, and is a low probability event, so the estimate is serial board or there is something wrong with the serial port line ~!
  • Related