Changeset 15 in flair-src for trunk/lib/FlairCore/src/Unix_SerialPort.h
- Timestamp:
- Apr 8, 2016, 3:40:57 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/Unix_SerialPort.h
r2 r15 17 17 #include <termios.h> /* POSIX terminal control definitions */ 18 18 19 namespace flair 20 { 21 namespace core 22 { 23 /*! \class RTDM_I2cPort 24 * 25 * \brief Class for unix serial port 26 * 27 */ 28 class Unix_SerialPort: public SerialPort 29 { 19 namespace flair { 20 namespace core { 21 /*! \class RTDM_I2cPort 22 * 23 * \brief Class for unix serial port 24 * 25 */ 26 class Unix_SerialPort : public SerialPort { 30 27 31 public: 32 /*! 33 * \brief Constructor 34 * 35 * Construct an unix serial port, with the following default values: \n 36 * - 115200bps baudrate 37 * 38 * \param parent parent 39 * \param name name 40 * \param device serial device (ex rtser1) 41 */ 42 Unix_SerialPort(const Object* parent,std::string port_name,std::string device); 28 public: 29 /*! 30 * \brief Constructor 31 * 32 * Construct an unix serial port, with the following default values: \n 33 * - 115200bps baudrate 34 * 35 * \param parent parent 36 * \param name name 37 * \param device serial device (ex rtser1) 38 */ 39 Unix_SerialPort(const Object *parent, std::string port_name, 40 std::string device); 43 41 44 45 46 47 48 42 /*! 43 * \brief Destructor 44 * 45 */ 46 ~Unix_SerialPort(); 49 47 50 51 52 53 54 55 56 48 /*! 49 * \brief Set baudrate 50 * 51 * \param baudrate baudrate 52 * 53 */ 54 void SetBaudrate(int baudrate); 57 55 58 59 60 61 62 63 64 65 56 /*! 57 * \brief Set RX timeout 58 * 59 * Timeout for waiting datas. 60 * 61 * \param timeout_ns timeout in nano second 62 */ 63 void SetRxTimeout(Time timeout_ns); 66 64 67 68 69 70 71 72 73 74 75 ssize_t Write(const void *buf,size_t nbyte);65 /*! 66 * \brief Write datas 67 * 68 * \param buf pointer to datas 69 * \param nbyte length of datas 70 * 71 * \return amount of written datas 72 */ 73 ssize_t Write(const void *buf, size_t nbyte); 76 74 77 78 79 80 81 82 83 84 85 ssize_t Read(void *buf,size_t nbyte);75 /*! 76 * \brief Read datas 77 * 78 * \param buf pointer to datas 79 * \param nbyte length of datas 80 * 81 * \return amount of read datas 82 */ 83 ssize_t Read(void *buf, size_t nbyte); 86 84 87 88 89 90 91 85 /*! 86 * \brief Flush input datas 87 * 88 */ 89 void FlushInput(void); 92 90 93 94 95 96 91 private: 92 int fd; 93 struct termios options; 94 }; 97 95 } // end namespace core 98 96 } // end namespace flair
Note:
See TracChangeset
for help on using the changeset viewer.