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.

55 lines
1.4 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
4 years ago
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
6 years ago
7 years ago
​
​
  1. #ifndef __SERIALPORT_H_INCL__
  2. #define __SERIALPORT_H_INCL__
  3. #include <stdio.h> // standard input / output functions
  4. #include <stdlib.h>
  5. #include <string.h> // string function definitions
  6. #include <fcntl.h> // File control definitions
  7. #include <errno.h> // Error number definitions
  8. #ifdef __linux__
  9. #include <unistd.h> // UNIX standard function definitions
  10. #include <termios.h> // POSIX terminal control 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. private:
  26. basicLogCollection *m_pLog;
  27. #ifdef __linux__
  28. struct termios m_sTTY;
  29. int m_iInFID;
  30. int m_iOutFID;
  31. #else
  32. DCB PortDCB;
  33. HANDLE m_ioFID;
  34. #endif
  35. CSTR m_sDevicePath;
  36. int m_iLineSpeed;
  37. bool m_bInitComplete;
  38. bool HW_init( CSTR DevicePath, int Speed );
  39. protected:
  40. int sendBlock( unsigned char *Data, int DataSize );
  41. int recptBlock( unsigned char *Buffer, int *BufferLength );
  42. public:
  43. serialPort();
  44. serialPort( CSTR DevicePath, int Speed );
  45. virtual ~serialPort();
  46. bool create( CSTR DevicePath, int Speed );
  47. };
  48. #endif // __SERIALPORT_H_INCL__