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.

59 lines
1.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __SERIALPORT_H_INCL__
  2. #define __SERIALPORT_H_INCL__
  3. #include <errno.h> // Error number definitions
  4. #include <fcntl.h> // File control definitions
  5. #include <stdio.h> // standard input / output functions
  6. #include <stdlib.h>
  7. #include <string.h> // string function definitions
  8. #ifdef __linux__
  9. #include <termios.h> // POSIX terminal control definitions
  10. #include <unistd.h> // UNIX standard function definitions
  11. #else
  12. #endif
  13. #include "../../data/transport/transportSerial.h"
  14. #ifdef DEBUG_EXTRA
  15. // #ifdef DEBUG_COMMUNICATION
  16. // #define DEBUG_SERIAL_COMMUNICATION
  17. // #endif
  18. #endif
  19. /**
  20. * TODO: Add class description
  21. *
  22. * @author gagua
  23. */
  24. class serialPort : public transportSerial
  25. {
  26. private:
  27. basicLogCollection * m_pLog;
  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. CSTR m_sDevicePath;
  37. int m_iLineSpeed;
  38. bool m_bInitComplete;
  39. bool HW_init(CSTR DevicePath, int Speed);
  40. protected:
  41. int sendBlock(unsigned char * Data, int DataSize);
  42. int recptBlock(unsigned char * Buffer, int * BufferLength);
  43. public:
  44. serialPort();
  45. serialPort(CSTR DevicePath, int Speed);
  46. virtual ~serialPort();
  47. bool create(CSTR DevicePath, int Speed);
  48. };
  49. #endif // __SERIALPORT_H_INCL__