C++语言封装的串口,可以直接调用;
class CSerial : public iSerial
{
public:
CSerial();
~CSerial();
BOOL Open( int nPort , int nBaud ,int BAU ,int PAR , int STO);
BOOL Close( void );
int ReadData( void *, int );
int SendData( const char *, int );
int SendData( const unsigned char *, int );
int ReadDataWaiting( void );
//int Write(unsigned char[] WriteBytes);
BOOL IsOpened( void ){ return( m_bOpened ); }
protected:
BOOL WriteCommByte( unsigned char );
HANDLE m_hIDComDev;
OVERLAPPED m_OverlappedRead, m_OverlappedWrite;
BOOL m_bOpened;
// afx_msg void OnSerial(void);
// DECLARE_EVENTSINK_MAP();
};
2021-05-01 23:50:31
2KB
串口
1