我写了一个串口程序,在模拟器PPC2003上调试是可以的,能正常的打开串口并收发数据,但部署到真机(WINCE5)串口都打不开,代码如下:
- try
- {
- serialPort1.Parity = System.IO.Ports.Parity.None;
- serialPort1.StopBits = System.IO.Ports.StopBits.One;
- serialPort1.BaudRate = 9600;
- serialPort1 .DataBits =8;
- serialPort1.PortName = "COM2";
- serialPort1.ReadBufferSize = 1024;
- serialPort1.WriteBufferSize = 1024;
- serialPort1.WriteTimeout = 200;
- serialPort1.Open();
- serialPort1.ReadExisting();//设置Input从接收缓冲读取全部数据
- serialPort1.ReceivedBytesThreshold = 1;//设置引发OnComm事件的字节长度
- serialPort1.DiscardInBuffer();//清除接收缓冲区
- serialPort1.DiscardOutBuffer(); //清除发送缓冲区
- }
- catch (System .Exception ex)
- {
- labState.Text = "请重新配置串口!请检查"+ex.Message;
- }
请指点一下??