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.

68 lines
2.4 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. #ifdef DEBUG
  16. //#define DEBUG_SERIAL_COMMUNICATION
  17. #endif
  18. #define MAXIMAL_SOCKET_PACKET_LENGTH 102400
  19. #ifndef MAXIMAL_SERIAL_PACKET_LENGTH
  20. #define MAXIMAL_SERIAL_PACKET_LENGTH MAXIMAL_SOCKET_PACKET_LENGTH
  21. #endif
  22. class argusHardwareResourceSerialProvider: public argusHardwareResource, public basicTransport, public basicDualThread {
  23. private:
  24. basicLogCollection * m_pLog;
  25. DBC_UART_DATA m_sUartData;
  26. int m_iDeviceFD;
  27. int m_iMasterFD;
  28. #ifdef __linux__
  29. struct termios m_sTTY;
  30. int m_iInFID;
  31. int m_iOutFID;
  32. #else
  33. DCB PortDCB;
  34. HANDLE m_ioFID;
  35. #endif
  36. bool pingDevice();
  37. bool create_SOL();
  38. bool create_HW();
  39. bool closePort();
  40. int sendBlock(unsigned char *Data, int DataSize);
  41. int recptBlock(unsigned char *Buffer, int *BufferLength);
  42. protected:
  43. U8 m_pInputBuffer[MAXIMAL_SOCKET_PACKET_LENGTH];
  44. U8 m_pOutputBuffer[MAXIMAL_SOCKET_PACKET_LENGTH];
  45. int m_nInputBufferSize;
  46. int m_nOutputBufferSize;
  47. virtual void m_fThreadAProc(void);
  48. virtual void m_fThreadBProc(void);
  49. public:
  50. explicit argusHardwareResourceSerialProvider( uint32_t dbID );
  51. virtual ~argusHardwareResourceSerialProvider();
  52. virtual bool create( void );
  53. virtual bool validate( void );
  54. virtual bool sendData( uint8_t *Data, int DataSize );
  55. virtual bool reconnect( void );
  56. };
  57. #endif