source: flair-src/trunk/lib/FlairCore/src/Unix_I2cPort.h@ 15

Last change on this file since 15 was 15, checked in by Bayard Gildas, 6 years ago

sources reformatted with flair-format-dir script

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_I2cPort.h
7 * \brief Class for unix i2c port
8 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
9 * \date 2014/08/28
10 * \version 4.0
11 */
12
13#ifndef UNIX_I2CPORT_H
14#define UNIX_I2CPORT_H
15
16#include <I2cPort.h>
17
18namespace flair {
19namespace core {
20/*! \class Unix_I2cPort
21*
22* \brief Class for unix serial port
23*
24*/
25class Unix_I2cPort : public I2cPort {
26
27public:
28 /*!
29 * \brief Constructor
30 *
31 * Construct an unix i2c port
32 *
33 * \param parent parent
34 * \param name name
35 * \param device serial device (ex /dev/i2c-1)
36 */
37 Unix_I2cPort(const Object *parent, std::string port_name, std::string device);
38
39 /*!
40 * \brief Destructor
41 *
42 */
43 ~Unix_I2cPort();
44
45 /*!
46 * \brief Set slave's address
47 *
48 * This method need to be called before any communication.
49 *
50 * \param address slave's address
51 */
52 int SetSlave(uint16_t address);
53
54 /*!
55 * \brief Set RX timeout
56 *
57 * Timeout for waiting datas.
58 *
59 * \param timeout_ns timeout in nano second
60 */
61 void SetRxTimeout(Time timeout_ns);
62
63 /*!
64 * \brief Set TX timeout
65 *
66 * Timeout for waiting an ACK from the slave.
67 *
68 * \param timeout_ns timeout in nano second
69 */
70 void SetTxTimeout(Time timeout_ns);
71
72 /*!
73 * \brief Write datas
74 *
75 * \param buf pointer to datas
76 * \param nbyte length of datas
77 *
78 * \return amount of written datas
79 */
80 ssize_t Write(const void *buf, size_t nbyte);
81
82 /*!
83 * \brief Read datas
84 *
85 * \param buf pointer to datas
86 * \param nbyte length of datas
87 *
88 * \return amount of read datas
89 */
90 ssize_t Read(void *buf, size_t nbyte);
91
92private:
93 int fd;
94};
95} // end namespace core
96} // end namespace flair
97
98#endif // UNIX_I2CPORT_H
Note: See TracBrowser for help on using the repository browser.