72 lines
2.0 KiB
C++
72 lines
2.0 KiB
C++
|
#ifndef _UART_H_
|
||
|
#define _UART_H_
|
||
|
#include <list>
|
||
|
#include <map>
|
||
|
#include <iostream>
|
||
|
#include <boost/asio.hpp>
|
||
|
#include <boost/thread/mutex.hpp>
|
||
|
#include <boost/unordered_set.hpp>
|
||
|
#include <boost/unordered_map.hpp>
|
||
|
#include "../utility/SH_MySingleton.hpp"
|
||
|
#include "../common/SH_CommonFunc.hpp"
|
||
|
#include "../common/SH_global.h"
|
||
|
#include "../dbaccess/SH_SqlDB.hpp"
|
||
|
|
||
|
|
||
|
|
||
|
//using namespace boost::asio;
|
||
|
//using std::string;
|
||
|
//using boost::system::error_code;
|
||
|
typedef unsigned int UINT;
|
||
|
|
||
|
|
||
|
class Uart : public MySingleton<Uart>
|
||
|
{
|
||
|
private :
|
||
|
boost::posix_time::ptime mLocalTime;
|
||
|
boost::asio::io_service mIoSev;
|
||
|
boost::asio::serial_port mUart;
|
||
|
int mRdLength;
|
||
|
enum{BUF_LENGTH = 1024};
|
||
|
char mUartRecvBuf[BUF_LENGTH];
|
||
|
boost::mutex mLock;
|
||
|
boost::asio::io_service::strand mStrand;
|
||
|
|
||
|
public :
|
||
|
Uart();
|
||
|
void InitUart();
|
||
|
~Uart();
|
||
|
void WriteToUart(const char *strSend,int pLen);
|
||
|
void ReadFromUart();
|
||
|
void setCallBack(onReceiveUart _callback);
|
||
|
void Run();
|
||
|
void Stop();
|
||
|
void UpdateZigbeeInfoCtrl();
|
||
|
void UpdateZigbeeInfo(const char *pData);
|
||
|
void DealRecvData(const char *pData);
|
||
|
void DealDataNodeInfo(const char *pData);
|
||
|
void DealDataNodeFeature(const char *pData, int flag);
|
||
|
void DealDataNodeWave(const char *pData);
|
||
|
void DealWaveThread();
|
||
|
void DealWave();
|
||
|
void ZigbeeInit();
|
||
|
|
||
|
void modify_info(unsigned short id, char * zigbee);
|
||
|
void zigbee_reset(unsigned short pad, unsigned short type);
|
||
|
void WriteChanl2Zigbee(unsigned char pad);
|
||
|
void WritePanId2Zigbee(unsigned short pad);
|
||
|
void WriteShortAddr2Zigbee(unsigned short pad);
|
||
|
virtual void DataAnalysis_R(DevDataOfGwid &pData);
|
||
|
virtual void DataAnalysis_W(DevData &pData,bool pFlag);
|
||
|
virtual void ThreadInit();
|
||
|
private :
|
||
|
void ReadHandle(const boost::system::error_code &ec,size_t bytesRead);
|
||
|
void WriteHandle(const char *strSend,const boost::system::error_code &ec,size_t bytesWrite);
|
||
|
onReceiveUart m_callback;
|
||
|
std::vector<RecvData> m_VecWaveData;
|
||
|
unsigned long m_TimeStamp;
|
||
|
};
|
||
|
|
||
|
|
||
|
#endif
|