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 SerialPort.h
|
---|
7 | * \brief Base class for serial port
|
---|
8 | * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
9 | * \date 2014/04/25
|
---|
10 | * \version 4.0
|
---|
11 | */
|
---|
12 |
|
---|
13 | #ifndef SERIALPORT_H
|
---|
14 | #define SERIALPORT_H
|
---|
15 |
|
---|
16 | #include <Object.h>
|
---|
17 | #include <stdint.h>
|
---|
18 |
|
---|
19 | namespace flair {
|
---|
20 | namespace core {
|
---|
21 | /*! \class SerialPort
|
---|
22 | *
|
---|
23 | * \brief Base class for serial port
|
---|
24 | */
|
---|
25 | class SerialPort : public Object {
|
---|
26 | public:
|
---|
27 | /*!
|
---|
28 | * \brief Constructor
|
---|
29 | *
|
---|
30 | * Construct a serial port.
|
---|
31 | *
|
---|
32 | * \param parent parent
|
---|
33 | * \param name name
|
---|
34 | */
|
---|
35 | SerialPort(const Object *parent, std::string name) : Object(parent, name) {}
|
---|
36 |
|
---|
37 | /*!
|
---|
38 | * \brief Destructor
|
---|
39 | *
|
---|
40 | */
|
---|
41 | ~SerialPort(){};
|
---|
42 |
|
---|
43 | /*!
|
---|
44 | * \brief Set baudrate
|
---|
45 | *
|
---|
46 | * \param baudrate baudrate
|
---|
47 | *
|
---|
48 | */
|
---|
49 | virtual void SetBaudrate(int baudrate) = 0;
|
---|
50 |
|
---|
51 | /*!
|
---|
52 | * \brief Set RX timeout
|
---|
53 | *
|
---|
54 | * Timeout for waiting datas.
|
---|
55 | *
|
---|
56 | * \param timeout_ns timeout in nano second
|
---|
57 | */
|
---|
58 | virtual void SetRxTimeout(Time timeout_ns) = 0;
|
---|
59 |
|
---|
60 | /*!
|
---|
61 | * \brief Write datas
|
---|
62 | *
|
---|
63 | * \param buf pointer to datas
|
---|
64 | * \param nbyte length of datas
|
---|
65 | *
|
---|
66 | * \return amount of written datas
|
---|
67 | */
|
---|
68 | virtual ssize_t Write(const void *buf, size_t nbyte) = 0;
|
---|
69 |
|
---|
70 | /*!
|
---|
71 | * \brief Read datas
|
---|
72 | *
|
---|
73 | * \param buf pointer to datas
|
---|
74 | * \param nbyte length of datas
|
---|
75 | *
|
---|
76 | * \return amount of read datas
|
---|
77 | */
|
---|
78 | virtual ssize_t Read(void *buf, size_t nbyte) = 0;
|
---|
79 |
|
---|
80 | /*!
|
---|
81 | * \brief Flush input datas
|
---|
82 | *
|
---|
83 | */
|
---|
84 | virtual void FlushInput(void) = 0;
|
---|
85 | };
|
---|
86 | } // end namespace core
|
---|
87 | } // end namespace flair
|
---|
88 |
|
---|
89 | #endif // SERIALPORT_H
|
---|