19 struct i2c_smbus_ioctl_data;
21 namespace duds {
namespace hardware {
namespace interface {
namespace linux {
57 void io(i2c_smbus_ioctl_data &sdat);
74 DevSmbus(
const std::string &devname,
int devaddr,
bool pec =
true);
103 DevSmbus(devname, devaddr, false) { }
111 virtual std::uint8_t
receiveByte(std::uint8_t cmd);
112 virtual std::uint16_t
receiveWord(std::uint8_t cmd);
118 virtual void receive(std::uint8_t cmd, std::vector<std::uint8_t> &in);
121 virtual void transmitByte(std::uint8_t cmd, std::uint8_t byte);
122 virtual void transmitWord(std::uint8_t cmd, std::uint16_t word);
125 const std::uint8_t *out,
128 virtual std::uint16_t
call(std::uint8_t cmd, std::uint16_t word);
131 const std::vector<std::uint8_t> &out,
132 std::vector<std::uint8_t> &in
DevSmbus(const std::string &devname, int devaddr, bool pec=true)
Opens the device file for the bus.
virtual void transmitByte(std::uint8_t byte)
Sends a single byte to the device.
virtual int receive(std::uint8_t cmd, std::uint8_t *in, const int maxlen)
Sends a command byte, then reads a block of data from the device.
Use with constructors to specify that Packet Error Checking (PEC) will not be used.
Implementation of the Smbus interface using the Linux kernel's user-space support.
~DevSmbus()
Closes the device file.
virtual int address() const
Returns the address of the device that this object will attempt to communicate with.
DevSmbus(const std::string &devname, int devaddr, NoPec)
Opens the device file for the bus and specifies that Packet Error Checking (PEC) will not be used...
An interface for communication with a SMBus device.
virtual void transmit(std::uint8_t cmd, const std::uint8_t *out, const int len)
Sends a command byte and a block of data to the device.
virtual std::uint8_t receiveByte()
Read a single byte from the device without sending a command/register byte first. ...
int addr
The device (slave) address; used for error reporting.
Use with constructors to explicitly specify that Packet Error Checking (PEC) be used.
int fd
The file descriptor for the open device.
void io(i2c_smbus_ioctl_data &sdat)
Sends I/O requests to the kernel, then checks for an error and if found throws the appropriate except...
std::string dev
Stores the device file name for later error reporting.
virtual std::uint16_t receiveWord(std::uint8_t cmd)
Sends a command byte, then reads a word, two bytes, from the device.
virtual void transmitWord(std::uint8_t cmd, std::uint16_t word)
Sends a command byte and a data word to the device.
virtual std::uint16_t call(std::uint8_t cmd, std::uint16_t word)
Does a process call operation.
DevSmbus(const std::string &devname, int devaddr, UsePec)
Opens the device file for the bus and specifies that Packet Error Checking (PEC) will be used...
virtual void transmitBool(bool out)
Sends a single bit to the device.