DUDS
Distributed Update of Data from Something
DevI2c.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2017 Jeff Jackowski
9  */
11 #include <string>
12 
13 #ifdef linux
14 // !@?!#?!#?
15 #undef linux
16 #endif
17 
18 struct i2c_rdwr_ioctl_data;
19 
20 namespace duds { namespace hardware { namespace interface { namespace linux {
21 
40  std::string dev;
44  int fd;
48  int addr;
53  void io(i2c_rdwr_ioctl_data &idat);
54 public:
65  DevI2c(const std::string &devname, int devaddr);
69  ~DevI2c();
102  virtual void converse(Conversation &conv);
103  virtual int address() const;
104 };
105 
106 } } } }
Implementation of the I2c interface using the Linux kernel&#39;s user-space support.
Definition: DevI2c.hpp:36
DevI2c(const std::string &devname, int devaddr)
Opens the device file for the bus.
Definition: DevI2c.cpp:23
virtual void converse(Conversation &conv)
Conducts I2C communication with a device using the Linux i2c-dev driver.
Definition: DevI2c.cpp:98
void io(i2c_rdwr_ioctl_data &idat)
Calls ioctl to request the kernel do the I2C communication, the check for error conditions and throw ...
Definition: DevI2c.cpp:43
static std::wstring_convert< std::codecvt_utf8< char32_t >, char32_t > conv
String converter; UTF-8 to/from UTF-32.
Definition: BppFont.cpp:165
A basic I2C interface.
Definition: I2c.hpp:22
int addr
The device (slave) address.
Definition: DevI2c.hpp:48
~DevI2c()
Closes the device file.
Definition: DevI2c.cpp:39
virtual int address() const
Returns the address of the device that this object will attempt to communicate with.
Definition: DevI2c.cpp:164
int fd
The file descriptor for the open device.
Definition: DevI2c.hpp:44
std::string dev
Stores the device file name for later error reporting.
Definition: DevI2c.hpp:40
Represents a two-way conversation with a device.