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

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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/select.h>
  7. #include <sys/types.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. {
  17. private:
  18. basicLogCollection * m_pLog;
  19. #ifdef PUSH_PULL_MODE
  20. basicMutex m_mCmdSent;
  21. uint16_t m_nCmdSentTO;
  22. #endif
  23. basicMutex m_mIsBusy;
  24. void m_fThreadAProc(void);
  25. void m_fThreadBProc(void);
  26. protected:
  27. U8 * m_pInputBuffer;
  28. int m_nInputBufferSize;
  29. U8 * m_pOutputBuffer;
  30. int m_nOutputBufferSize;
  31. int m_nSenderSetMax;
  32. int m_nReaderSetMax;
  33. fd_set m_sSenderSet;
  34. fd_set m_sReaderSet;
  35. int m_iControlPipeFD[2];
  36. virtual int sendBlock(unsigned char * Data, int DataSize)
  37. {
  38. if ( Data || DataSize ) return 0;
  39. return 0;
  40. }
  41. virtual int recptBlock(unsigned char * Buffer, int * BufferLength)
  42. {
  43. if ( Buffer || BufferLength ) return 0;
  44. return 0;
  45. }
  46. public:
  47. transportSerial();
  48. virtual ~transportSerial();
  49. bool sendData(unsigned char * Data, int DataSize);
  50. virtual bool create(void);
  51. virtual bool _close(void);
  52. };
  53. #endif