RADLib
RADical C++ application framework
RADDevice::I2CDevice Class Reference

Parity-free I2C device wrapper using /dev/i2c-* and I2C_SLAVE ioctl. More...

#include <RADDevice.h>

Public Member Functions

 I2CDevice ()
 Creates a closed I2C device wrapper. More...
 
 ~I2CDevice ()
 Closes the device. More...
 
bool open (int bus, int address, const DevicePaths &paths={}, std::string *error=nullptr)
 Opens bus number and selects 7-bit address. More...
 
void close ()
 Closes the descriptor. More...
 
ssize_t write (const std::vector< uint8_t > &bytes)
 Writes bytes to the selected device. More...
 
std::vector< uint8_t > read (size_t count)
 Reads bytes from the selected device. More...
 
bool isOpen () const
 Returns true when open. More...
 
int fd () const
 Returns owned file descriptor. More...
 

Detailed Description

Parity-free I2C device wrapper using /dev/i2c-* and I2C_SLAVE ioctl.

Constructor & Destructor Documentation

◆ I2CDevice()

RADDevice::I2CDevice::I2CDevice ( )

Creates a closed I2C device wrapper.

◆ ~I2CDevice()

RADDevice::I2CDevice::~I2CDevice ( )

Closes the device.

Member Function Documentation

◆ close()

void RADDevice::I2CDevice::close ( )

Closes the descriptor.

◆ fd()

int RADDevice::I2CDevice::fd ( ) const

Returns owned file descriptor.

◆ isOpen()

bool RADDevice::I2CDevice::isOpen ( ) const

Returns true when open.

◆ open()

bool RADDevice::I2CDevice::open ( int  bus,
int  address,
const DevicePaths paths = {},
std::string *  error = nullptr 
)

Opens bus number and selects 7-bit address.

◆ read()

std::vector<uint8_t> RADDevice::I2CDevice::read ( size_t  count)

Reads bytes from the selected device.

◆ write()

ssize_t RADDevice::I2CDevice::write ( const std::vector< uint8_t > &  bytes)

Writes bytes to the selected device.


The documentation for this class was generated from the following file: