[2] | 1 | // %flair:license{
|
---|
| 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
| 4 | // %flair:license}
|
---|
| 5 | /*!
|
---|
| 6 | * \file RTDM_SerialPort.h
|
---|
| 7 | * \brief Class for real time serial port using RTDM
|
---|
| 8 | * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 9 | * \date 2011/08/19
|
---|
| 10 | * \version 4.0
|
---|
| 11 | */
|
---|
| 12 |
|
---|
| 13 | #ifndef RTDM_SERIALPORT_H
|
---|
| 14 | #define RTDM_SERIALPORT_H
|
---|
| 15 |
|
---|
| 16 | #include <SerialPort.h>
|
---|
| 17 |
|
---|
| 18 | namespace flair
|
---|
| 19 | {
|
---|
| 20 | namespace core
|
---|
| 21 | {
|
---|
| 22 | /*! \class RTDM_SerialPort
|
---|
| 23 | *
|
---|
| 24 | * \brief Class for real time serial port using RTDM
|
---|
| 25 | *
|
---|
| 26 | * This class can only be used with the real time version of Framework library.
|
---|
| 27 | *
|
---|
| 28 | */
|
---|
| 29 | class RTDM_SerialPort: public SerialPort
|
---|
| 30 | {
|
---|
| 31 |
|
---|
| 32 | public:
|
---|
| 33 | /*!
|
---|
| 34 | * \brief Constructor
|
---|
| 35 | *
|
---|
| 36 | * Construct an RTDM serial port, with the following default values: \n
|
---|
| 37 | * - 115200bps baudrate
|
---|
| 38 | *
|
---|
| 39 | * \param parent parent
|
---|
| 40 | * \param name name
|
---|
| 41 | * \param device serial device (ex rtser1)
|
---|
| 42 | */
|
---|
| 43 | RTDM_SerialPort(const Object* parent,std::string port_name,std::string device);
|
---|
| 44 |
|
---|
| 45 | /*!
|
---|
| 46 | * \brief Destructor
|
---|
| 47 | *
|
---|
| 48 | */
|
---|
| 49 | ~RTDM_SerialPort();
|
---|
| 50 |
|
---|
| 51 | /*!
|
---|
| 52 | * \brief Set baudrate
|
---|
| 53 | *
|
---|
| 54 | * \param baudrate baudrate
|
---|
| 55 | *
|
---|
| 56 | */
|
---|
| 57 | void SetBaudrate(int baudrate);
|
---|
| 58 |
|
---|
| 59 | /*!
|
---|
| 60 | * \brief Set RX timeout
|
---|
| 61 | *
|
---|
| 62 | * Timeout for waiting datas.
|
---|
| 63 | *
|
---|
| 64 | * \param timeout_ns timeout in nano second
|
---|
| 65 | */
|
---|
| 66 | void SetRxTimeout(Time timeout_ns);
|
---|
| 67 |
|
---|
| 68 | /*!
|
---|
| 69 | * \brief Write datas
|
---|
| 70 | *
|
---|
| 71 | * \param buf pointer to datas
|
---|
| 72 | * \param nbyte length of datas
|
---|
| 73 | *
|
---|
| 74 | * \return amount of written datas
|
---|
| 75 | */
|
---|
| 76 | ssize_t Write(const void *buf,size_t nbyte);
|
---|
| 77 |
|
---|
| 78 | /*!
|
---|
| 79 | * \brief Read datas
|
---|
| 80 | *
|
---|
| 81 | * \param buf pointer to datas
|
---|
| 82 | * \param nbyte length of datas
|
---|
| 83 | *
|
---|
| 84 | * \return amount of read datas
|
---|
| 85 | */
|
---|
| 86 | ssize_t Read(void *buf,size_t nbyte);
|
---|
| 87 |
|
---|
| 88 | /*!
|
---|
| 89 | * \brief Flush input datas
|
---|
| 90 | *
|
---|
| 91 | */
|
---|
| 92 | void FlushInput(void);
|
---|
| 93 |
|
---|
| 94 | private:
|
---|
| 95 | int fd;
|
---|
| 96 | };
|
---|
| 97 | } // end namespace core
|
---|
| 98 | } // end namespace flair
|
---|
| 99 |
|
---|
| 100 | #endif // RTDM_SERIALPORT_H
|
---|