救助:VC mfc,使用ReadFile读串口,读不到16进制00
救助:VC mfc,使用ReadFile读串口,读不到16进制00
char r_buf[1024];
bResult=ReadFile(h_comm[num],r_buf,10,&len,0);
假设我发送:01 00 02
但是提示收到的长度只有2,中间的0x00丢掉了。。
[解决办法]
typedef struct _DCB { // dcb
DWORD DCBlength; // sizeof(DCB)
DWORD BaudRate; // current baud rate
DWORD fBinary: 1; // binary mode, no EOF check
DWORD fParity: 1; // enable parity checking
DWORD fOutxCtsFlow:1; // CTS output flow control
DWORD fOutxDsrFlow:1; // DSR output flow control
DWORD fDtrControl:2; // DTR flow control type
DWORD fDsrSensitivity:1; // DSR sensitivity
DWORD fTXContinueOnXoff:1; // XOFF continues Tx
DWORD fOutX: 1; // XON/XOFF out flow control
DWORD fInX: 1; // XON/XOFF in flow control
DWORD fErrorChar: 1; // enable error replacement
DWORD fNull: 1; // enable null stripping