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.

54 lines
1.6 KiB

8 years ago
​
​
​
3 years ago
8 years ago
​
​
​
​
4 years ago
8 years ago
3 years ago
​
​
​
8 years ago
​
​
​
3 years ago
​
​
​
​
8 years ago
​
​
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
​
​
8 years ago
​
​
​
​
  1. #ifndef __TRANSPORT_SERIAL_HEADERS__
  2. #define __TRANSPORT_SERIAL_HEADERS__
  3. #include "../../components/base/basicDualThread.h"
  4. #include "../../components/base/basicMutex.h"
  5. #include "../../components/base/basicTransport.h"
  6. #include <sys/types.h>
  7. #include <sys/select.h>
  8. #include <unistd.h>
  9. //#define DEBUG_COMMUNICATION
  10. #define MAXIMAL_SERIAL_PACKET_LENGTH 1024
  11. //#define PUSH_PULL_MODE
  12. #ifdef PUSH_PULL_MODE
  13. #define DEFAULT_PUSH_PULL_TO 200 //200 msec
  14. #endif
  15. class transportSerial: public basicTransport, public basicDualThread {
  16. private:
  17. basicLogCollection *m_pLog;
  18. #ifdef PUSH_PULL_MODE
  19. basicMutex m_mCmdSent;
  20. uint16_t m_nCmdSentTO;
  21. #endif
  22. basicMutex m_mIsBusy;
  23. void m_fThreadAProc(void);
  24. void m_fThreadBProc(void);
  25. protected:
  26. U8 * m_pInputBuffer;
  27. int m_nInputBufferSize;
  28. U8 * m_pOutputBuffer;
  29. int m_nOutputBufferSize;
  30. int m_nSenderSetMax;
  31. int m_nReaderSetMax;
  32. fd_set m_sSenderSet;
  33. fd_set m_sReaderSet;
  34. int m_iControlPipeFD[2];
  35. virtual int sendBlock(unsigned char *Data, int DataSize){ return 0;};
  36. virtual int recptBlock(unsigned char *Buffer, int *BufferLength){ return 0;};
  37. public:
  38. transportSerial();
  39. virtual ~transportSerial();
  40. bool sendData( unsigned char *Data, int DataSize );
  41. virtual bool create( void );
  42. virtual bool _close( void );
  43. };
  44. #endif