physerver.h
来自「一个通讯管理机的源代码。比较好用。推荐」· C头文件 代码 · 共 98 行
H
98 行
/*************************************************************************** physerver.h - description ------------------- begin : Thu Jan 17 2002 copyright : (C) 2002 by email : ***************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************//*************************************************************************** physerver.h - description ------------------- begin : Fri Nov 2 2001 copyright : (C) 2001 by email : ***************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/#ifndef PHYSERVER_H#define PHYSERVER_H/** *@author *enum phyService { *ps_eSend,ps_eReceive,ps_eConnect,ps_eDisconnect, *}; */#include "msystem.h"#include "serial.h"using namespace Serial;void * ReadSerial(void * arg);class CPhyService : public CIOStream{public: CPhyService(CSerialPortDef *pChannel); ~CPhyService(); int Status()//-1:Disconnect,0:Idle,1:Busy { if (m_nStatus == -1) Connect(); return m_nStatus; } bool Write(BYTE *pData,WORD wSize) { bool bRet = false; if ((Status()==0) && (write(m_serial.GetFileHandle(),pData,wSize) == wSize)) { timeval tv; gettimeofday(&tv,NULL); AddIOStream(tv,pData,wSize); bRet = true; #ifdef _COMMONITOR cout << endl; cout << "->{" <<wSize << '}'; for (int nnn=0; nnn<wSize; nnn++) { char c[16]; sprintf(c," %02x ",pData[nnn]); cout << c; } #endif } return bRet; } bool Connect() ; void Disconnect(); bool Reset(); CDQue *GetRecvQueue() { return &m_queRecv; }protected: CSerial m_serial;//int m_hComDev; int m_nStatus; pthread_t m_hThread; CDQue m_queRecv; char *m_pszDevName; friend void *ReadSerial(void *);};#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?