m_SerialPort.InitPort(this,nPort,9600,"N",8,1,EV_RXFLAG|EV_RXCHAR,512)连接时提示:
  error C2664: 'InitPort' : cannot convert parameter 4 from 'char [2]' to 'char'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
请高手指点一下!

解决方案 »

  1.   

    CSerialPort.cpp中是这样的:
    m_hComm = CreateFile(szPort,      // communication port string (COMX)
    GENERIC_READ | GENERIC_WRITE, // read/write types
    0,        // comm devices must be opened with exclusive access
    NULL,       // no security attributes
    OPEN_EXISTING,     // comm devices must use OPEN_EXISTING
    FILE_FLAG_OVERLAPPED,   // Async I/O
    0);   
      

  2.   

    提示应该是数据类型转换时的错误,参考一下hCom的设置:
    HANDLE hCom =::CreateFile( _T("\\\\.\\COM11"),  //打開串口
    GENERIC_READ|GENERIC_WRITE, 
    0,
    0,
    OPEN_EXISTING,
    0,//FILE_FLAG_OVERLAPPED,
    0
    );
    if(hCom ==INVALID_HANDLE_VALUE)  //判斷串口是否打開
    {
    DWORD dwError=::GetLastError();
    return false;
    }
    这边是测试OK!
      

  3.   

    "N"改成'N'即可
    BOOL CSerialPort::InitPort()第四个参数为char  parity