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 | namespace core {
|
---|
20 | /*! \class RTDM_SerialPort
|
---|
21 | *
|
---|
22 | * \brief Class for real time serial port using RTDM
|
---|
23 | *
|
---|
24 | * This class can only be used with the real time version of Framework library.
|
---|
25 | *
|
---|
26 | */
|
---|
27 | class RTDM_SerialPort : public SerialPort {
|
---|
28 |
|
---|
29 | public:
|
---|
30 | /*!
|
---|
31 | * \brief Constructor
|
---|
32 | *
|
---|
33 | * Construct an RTDM serial port, with the following default values: \n
|
---|
34 | * - 115200bps baudrate
|
---|
35 | *
|
---|
36 | * \param parent parent
|
---|
37 | * \param name name
|
---|
38 | * \param device serial device (ex rtser1)
|
---|
39 | */
|
---|
40 | RTDM_SerialPort(const Object *parent, std::string port_name,
|
---|
41 | std::string device);
|
---|
42 |
|
---|
43 | /*!
|
---|
44 | * \brief Destructor
|
---|
45 | *
|
---|
46 | */
|
---|
47 | ~RTDM_SerialPort();
|
---|
48 |
|
---|
49 | /*!
|
---|
50 | * \brief Set baudrate
|
---|
51 | *
|
---|
52 | * \param baudrate baudrate
|
---|
53 | *
|
---|
54 | */
|
---|
55 | void SetBaudrate(int baudrate);
|
---|
56 |
|
---|
57 | /*!
|
---|
58 | * \brief Set RX timeout
|
---|
59 | *
|
---|
60 | * Timeout for waiting datas.
|
---|
61 | *
|
---|
62 | * \param timeout_ns timeout in nano second
|
---|
63 | */
|
---|
64 | void SetRxTimeout(Time timeout_ns);
|
---|
65 |
|
---|
66 | /*!
|
---|
67 | * \brief Write datas
|
---|
68 | *
|
---|
69 | * \param buf pointer to datas
|
---|
70 | * \param nbyte length of datas
|
---|
71 | *
|
---|
72 | * \return amount of written datas
|
---|
73 | */
|
---|
74 | ssize_t Write(const void *buf, size_t nbyte);
|
---|
75 |
|
---|
76 | /*!
|
---|
77 | * \brief Read datas
|
---|
78 | *
|
---|
79 | * \param buf pointer to datas
|
---|
80 | * \param nbyte length of datas
|
---|
81 | *
|
---|
82 | * \return amount of read datas
|
---|
83 | */
|
---|
84 | ssize_t Read(void *buf, size_t nbyte);
|
---|
85 |
|
---|
86 | /*!
|
---|
87 | * \brief Flush input datas
|
---|
88 | *
|
---|
89 | */
|
---|
90 | void FlushInput(void);
|
---|
91 |
|
---|
92 | private:
|
---|
93 | int fd;
|
---|
94 | };
|
---|
95 | } // end namespace core
|
---|
96 | } // end namespace flair
|
---|
97 |
|
---|
98 | #endif // RTDM_SERIALPORT_H
|
---|