⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d195.bmp.txt

📁 Visual C++通信编程工程实例精解(附盘)
💻 TXT
字号:
                          goto Exit;
                        }
                               // No idea what could cause another enor.
                        IRACE(_TEXT("Error writing to CommFile while waiting%x \n"),dwLastError);
 nRet=-l;
                    goto Exit;
                }
        }
        //Some data was written.    Make sure it all got written.
       dwCount -= dwHaveWritten:
        dwStartWnte += dwHaveWritten;
}while(dwCount > 0);   //Write the whole thing!
//Wrote the whole string.
nRet=l;
Exit:
//EscapeCommFunction(m_hFileHandle,CLRRTS);//半双工
if(nRet!=l)
  Purge(PURGE  TXABORT{ PURGE  'IXCLEAR);/,I汉消写操作
return nRet;
其中,参数lpszStringToWrite表示要写的字符串;参数dwCount表示字符串的长度。
10)设置串口参数。具体代码如下:
BOOL CYsComm::SetComm(int iBaud)
{
m_iBaud=iBaud;
   DCB dcb;
   BOOL fSuccess;
fSuccess = GetCommState(m_hFileHandle, &dcb);
 if ( !fSuccess)
 {
           // Handle the error.
TRACE(_TEXT("GetCommState failed with error  %d.\n"), GetLastError(》;
         return FALSE;
 }
dcb.fBinary=TRUE;
 dcb.BaudRate = iBaud;                // set the baud rate
dcb.ByteSize = 8;                    //data size, xmit, and rcv
dcb.Parity=O;//EVENPARITY;// Even paritybit
dcb.StopBits = ONESTOPBIT;   //one stop bit
dcb.fAbortOnError;;:FALSE;
195

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -