阅读:830回复:1
请教,关于串口通信
情况如下。我的CE上有一个红外接收器。它使用串口通信。我写了一个简单的测试程序。运行后不管按红外遥控器的哪个键。测试程序里收到的都是同样的一串字符。。。。
我在linux下写了同样一个测试程序。。却可以正确的收到字符。。。请问一下。这样子的情况会是些什么样的问题引起的呢? CE下的配置 PortDCB.DCBlength = sizeof( DCB ); GetCommState( hCom, &PortDCB ); PortDCB.BaudRate = CBR_9600; PortDCB.fBinary = TRUE; // Binary mode; no EOF check PortDCB.fParity = TRUE; // Enable parity checking PortDCB.fOutxCtsFlow = FALSE; // No CTS output flow control PortDCB.fOutxDsrFlow = FALSE; // No DSR output flow control //PortDCB.fDtrControl = DTR_CONTROL_ENABLE; PortDCB.fDtrControl = DTR_CONTROL_DISABLE; // DTR flow control type PortDCB.fDsrSensitivity = FALSE; // DSR sensitivity PortDCB.fTXContinueOnXoff = FALSE; // XOFF continues Tx PortDCB.fOutX = FALSE; // No XON/XOFF out flow control //PortDCB.fInX = TRUE; // No XON/XOFF in flow control PortDCB.fInX = FALSE; // No XON/XOFF in flow control PortDCB.fErrorChar = FALSE; // Disable error replacement PortDCB.fNull = FALSE; // Disable null stripping //PortDCB.fRtsControl = RTS_CONTROL_ENABLE; PortDCB.fRtsControl = RTS_CONTROL_DISABLE; // RTS flow control PortDCB.fAbortOnError = FALSE; // Do not abort reads/writes on // error PortDCB.ByteSize = 8; // Number of bits/byte, 4-8 PortDCB.Parity = NOPARITY; // 0-4=no,odd,even,mark,space PortDCB.StopBits = 0; // 0,1,2 = 1, 1.5, 2 ====================================== linux下的配置 newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD; newtio.c_iflag = IGNPAR; newtio.c_oflag = 0; newtio.c_lflag = 0; newtio.c_cc[VTIME] = 0; newtio.c_cc[VMIN] = 5; |
|
|
沙发#
发布于:2007-08-31 20:33
调用一下EscapeCommFunction( HANDLE hFile, SETIR);
|
|
|