You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.4 KiB
67 lines
1.4 KiB
#ifndef __TRANSPORT_SERIAL_HEADERS__
|
|
#define __TRANSPORT_SERIAL_HEADERS__
|
|
|
|
#include "../../components/base/basicDualThread.h"
|
|
#include "../../components/base/basicMutex.h"
|
|
#include "../../components/base/basicTransport.h"
|
|
|
|
#include <sys/select.h>
|
|
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
|
|
// #define DEBUG_COMMUNICATION
|
|
|
|
#define MAXIMAL_SERIAL_PACKET_LENGTH 1024
|
|
// #define PUSH_PULL_MODE
|
|
#ifdef PUSH_PULL_MODE
|
|
#define DEFAULT_PUSH_PULL_TO 200 // 200 msec
|
|
#endif
|
|
|
|
class transportSerial : public basicTransport, public basicDualThread
|
|
{
|
|
private:
|
|
|
|
basicLogCollection * m_pLog;
|
|
#ifdef PUSH_PULL_MODE
|
|
basicMutex m_mCmdSent;
|
|
uint16_t m_nCmdSentTO;
|
|
#endif
|
|
basicMutex m_mIsBusy;
|
|
void m_fThreadAProc(void);
|
|
void m_fThreadBProc(void);
|
|
|
|
protected:
|
|
|
|
U8 * m_pInputBuffer;
|
|
int m_nInputBufferSize;
|
|
U8 * m_pOutputBuffer;
|
|
int m_nOutputBufferSize;
|
|
|
|
int m_nSenderSetMax;
|
|
int m_nReaderSetMax;
|
|
fd_set m_sSenderSet;
|
|
fd_set m_sReaderSet;
|
|
int m_iControlPipeFD[2];
|
|
|
|
virtual int sendBlock(unsigned char * Data, int DataSize)
|
|
{
|
|
if ( Data || DataSize ) return 0;
|
|
return 0;
|
|
}
|
|
|
|
virtual int recptBlock(unsigned char * Buffer, int * BufferLength)
|
|
{
|
|
if ( Buffer || BufferLength ) return 0;
|
|
return 0;
|
|
}
|
|
|
|
public:
|
|
|
|
transportSerial();
|
|
virtual ~transportSerial();
|
|
bool sendData(unsigned char * Data, int DataSize);
|
|
virtual bool create(void);
|
|
virtual bool _close(void);
|
|
};
|
|
|
|
#endif
|