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.

54 lines
1.3 KiB

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. #ifdef DEBUG
  14. //#define _DEBUG_SERIAL_COMMUNICATION_
  15. #endif
  16. #include "../../data/transport/transportSerial.h"
  17. /**
  18. * TODO: Add class description
  19. *
  20. * @author gagua
  21. */
  22. class serialPort: public transportSerial {
  23. private:
  24. basicLogCollection *m_pLog;
  25. #ifdef __linux__
  26. struct termios m_sTTY;
  27. int m_iInFID;
  28. int m_iOutFID;
  29. #else
  30. DCB PortDCB;
  31. HANDLE m_ioFID;
  32. #endif
  33. CSTR m_sDevicePath;
  34. int m_iLineSpeed;
  35. bool m_bInitComplete;
  36. bool HW_init( CSTR DevicePath, int Speed );
  37. protected:
  38. int sendBlock( unsigned char *Data, int DataSize );
  39. int recptBlock( unsigned char *Buffer, int *BufferLength );
  40. public:
  41. serialPort();
  42. serialPort( CSTR DevicePath, int Speed );
  43. ~serialPort();
  44. bool addRecipient( protocolParser *ProtoParser );
  45. };
  46. #endif // __SERIALPORT_H_INCL__