source: flair-dev/trunk/include/FlairCore/Unix_SerialPort.h @ 76

Last change on this file since 76 was 13, checked in by Bayard Gildas, 5 years ago

formatting script + include reformatted

File size: 1.8 KB
Line 
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 Unix_SerialPort.h
7 * \brief Class for unix serial port
8 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
9 * \date 2011/08/19
10 * \version 4.0
11 */
12
13#ifndef UNIX_SERIALPORT_H
14#define UNIX_SERIALPORT_H
15
16#include <SerialPort.h>
17#include <termios.h> /* POSIX terminal control definitions */
18
19namespace flair {
20namespace core {
21/*! \class RTDM_I2cPort
22*
23* \brief Class for unix serial port
24*
25*/
26class Unix_SerialPort : public SerialPort {
27
28public:
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);
41
42  /*!
43  * \brief Destructor
44  *
45  */
46  ~Unix_SerialPort();
47
48  /*!
49  * \brief Set baudrate
50  *
51  * \param baudrate baudrate
52  *
53  */
54  void SetBaudrate(int baudrate);
55
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);
64
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);
74
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);
84
85  /*!
86  * \brief Flush input datas
87  *
88  */
89  void FlushInput(void);
90
91private:
92  int fd;
93  struct termios options;
94};
95} // end namespace core
96} // end namespace flair
97
98#endif // UNIX_SERIALPORT_H
Note: See TracBrowser for help on using the repository browser.