首页 > 其他 > 详细

【笔记】SerialPort类的实现

时间:2014-05-02 20:06:06      阅读:507      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
class CSerialPort
{                                                         
public:
    // contruction and destruction
    CSerialPort();
    virtual        ~CSerialPort();

    // port initialisation                                            
    BOOL        InitPort(CWnd* pPortOwner, 
              UINT portnr = 1,
              UINT baud = 19200,
              char parity = N,
              UINT databits = 8,
              UINT stopsbits = 1,
              DWORD dwCommEvents = EV_RXCHAR | EV_CTS,
              UINT nBufferSize = 512); // start/stop comm watching BOOL StartMonitoring(); BOOL RestartMonitoring(); BOOL StopMonitoring(); DWORD GetWriteBufferSize(); DWORD GetCommEvents(); DCB GetDCB(); void WriteToPort(char* string); protected: // protected memberfunctions void ProcessErrorMessage(char* ErrorText); static UINT CommThread(LPVOID pParam); static void ReceiveChar(CSerialPort* port, COMSTAT comstat); static void WriteChar(CSerialPort* port); // thread CWinThread* m_Thread; // synchronisation objects CRITICAL_SECTION m_csCommunicationSync; BOOL m_bThreadAlive; // handles HANDLE m_hShutdownEvent; HANDLE m_hComm; HANDLE m_hWriteEvent; // Event array. // One element is used for each event. There are two event handles for each port. // A Write event and a receive character event which is located in the overlapped structure (m_ov.hEvent). // There is a general shutdown when the port is closed. HANDLE m_hEventArray[3]; // structures OVERLAPPED m_ov; COMMTIMEOUTS  m_CommTimeouts; DCB m_dcb; // owner window CWnd* m_pOwner; // misc UINT m_nPortNr; char* m_szWriteBuffer; DWORD m_dwCommEvents; DWORD m_nWriteBufferSize; };
bubuko.com,布布扣

 1.串口的初始化

【笔记】SerialPort类的实现,布布扣,bubuko.com

【笔记】SerialPort类的实现

原文:http://www.cnblogs.com/Spritutu/p/3703383.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!