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.

60 lines
2.2 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __ARGUS_HARDWARE_SERIAL_PROVIDER_HEADER__
  2. #define __ARGUS_HARDWARE_SERIAL_PROVIDER_HEADER__
  3. #include "rgooseHardwareResource.h"
  4. #include "../components/base/basicTransport.h"
  5. #include "../components/base/basicDualThread.h"
  6. #include <stdio.h> // standard input / output functions
  7. #include <stdlib.h>
  8. #include <string.h> // string function definitions
  9. #include <fcntl.h> // File control definitions
  10. #include <errno.h> // Error number definitions
  11. #ifdef __linux__
  12. #include <unistd.h> // UNIX standard function definitions
  13. #include <termios.h> // POSIX terminal control definitions
  14. #endif
  15. #define MAXIMAL_SOCKET_PACKET_LENGTH 102400
  16. #define MAXIMAL_SERIAL_PACKET_LENGTH MAXIMAL_SOCKET_PACKET_LENGTH
  17. class argusHardwareResourceSerialProvider: public argusHardwareResource, public basicTransport, public basicDualThread {
  18. private:
  19. basicLogCollection * m_pLog;
  20. DBC_UART_DATA m_sUartData;
  21. int m_iDeviceFD;
  22. int m_iMasterFD;
  23. #ifdef __linux__
  24. struct termios m_sTTY;
  25. int m_iInFID;
  26. int m_iOutFID;
  27. #else
  28. DCB PortDCB;
  29. HANDLE m_ioFID;
  30. #endif
  31. bool pingDevice();
  32. bool create_SOL();
  33. bool create_HW();
  34. bool closePort();
  35. int sendBlock(unsigned char *Data, int DataSize);
  36. int recptBlock(unsigned char *Buffer, int *BufferLength);
  37. protected:
  38. U8 m_pInputBuffer[MAXIMAL_SOCKET_PACKET_LENGTH];
  39. U8 m_pOutputBuffer[MAXIMAL_SOCKET_PACKET_LENGTH];
  40. int m_nInputBufferSize;
  41. int m_nOutputBufferSize;
  42. virtual void m_fThreadAProc(void);
  43. virtual void m_fThreadBProc(void);
  44. public:
  45. explicit argusHardwareResourceSerialProvider( uint32_t dbID );
  46. virtual ~argusHardwareResourceSerialProvider();
  47. virtual bool create( void );
  48. virtual bool validate( void );
  49. virtual bool sendData( uint8_t *Data, int DataSize );
  50. virtual bool reconnect( void );
  51. };
  52. #endif