First, you should make sure that the data is sent out and the serial port received them. To ensure taht, you can link your computer to another with serial cable to see if you can receive the data sent by your computer.  Second, you should check the the nByteRead after the method of ReadData is called, it should contains the number of bytes you send.  Third, you should reset the buffer before you use it with 0x0.

解决方案 »

  1.   

    同意gzlucky的意见。“屯屯屯屯屯屯屯屯屯屯屯屯”是lpBuffe的初始数据。
    你可以在int nBytesRead = serial.ReadData(lpBuffer, 500);之前加一句ZeroMemory将缓冲区置空。
    至于你提到的将串口的2,3相连,你的意思是自已发送再自已接收吗?
    ,不过我没见过这种用法的。你用两台机相连试试。
      

  2.   

    不可能是初始化值。因为如果 串口没有数据过来的话,它的receive事件根本就不会触发。
      

  3.   

    这就是了,他在CTestDlg::OnButtonR() 中强行调用serial.ReadData(lpBuffer, 500);
    但是事实并没用收到信息。所以仍是初始数据呀。