PIDUINO
Loading...
Searching...
No Matches
Piduino::I2cDev::Info

Information class for I2C bus configuration and management. More...

#include <i2cdev.h>

Collaboration diagram for Piduino::I2cDev::Info:

Public Member Functions

 Info (int id=0)
 Constructs an Info object with the specified bus ID.
 
int id () const
 Gets the current I2C bus ID.
 
void setId (int id)
 Sets the I2C bus ID and updates the corresponding device path.
 
const std::string & path () const
 Gets the device path for this I2C bus.
 
bool setPath (const std::string &path)
 Sets the device path and extracts the corresponding bus ID.
 
bool exists () const
 Checks if the I2C bus device file exists on the system.
 
bool operator== (const Info &other)
 Equality comparison operator.
 
bool operator!= (const Info &other)
 Inequality comparison operator.
 

Static Public Member Functions

static std::string busPath (int id)
 Generates the device path for a given I2C bus ID.
 
static Info defaultBus ()
 Gets information about the default I2C bus on the system.
 
static std::deque< InfoavailableBuses ()
 Returns a list of available I2C buses on the system.
 

Static Public Attributes

static const int MaxBuses = 32
 Maximum number of I2C buses supported by the system.
 

Private Attributes

int _id
 The I2C bus ID.
 
std::string _path
 The device path (e.g., "/dev/i2c-0")
 

Detailed Description

Information class for I2C bus configuration and management.

This nested class encapsulates I2C bus information including bus ID, device path, and provides utility methods for bus discovery and validation.

Definition at line 44 of file i2cdev.h.

Constructor & Destructor Documentation

◆ Info()

Piduino::I2cDev::Info::Info ( int  id = 0)

Constructs an Info object with the specified bus ID.

Parameters
idThe I2C bus ID (default: 0)

Member Function Documentation

◆ availableBuses()

static std::deque< Info > Piduino::I2cDev::Info::availableBuses ( )
static

Returns a list of available I2C buses on the system.

Returns
A deque containing Info objects for all detected I2C buses

◆ busPath()

static std::string Piduino::I2cDev::Info::busPath ( int  id)
static

Generates the device path for a given I2C bus ID.

Parameters
idThe bus ID
Returns
The corresponding device path string (e.g., "/dev/i2c-0" for ID 0)

◆ defaultBus()

static Info Piduino::I2cDev::Info::defaultBus ( )
static

Gets information about the default I2C bus on the system.

Returns
An Info object representing the default I2C bus

◆ exists()

bool Piduino::I2cDev::Info::exists ( ) const
inline

Checks if the I2C bus device file exists on the system.

Returns
true if the device file exists and is accessible, false otherwise

◆ id()

int Piduino::I2cDev::Info::id ( ) const
inline

Gets the current I2C bus ID.

Returns
The bus ID as an integer

◆ operator!=()

bool Piduino::I2cDev::Info::operator!= ( const Info other)

Inequality comparison operator.

Parameters
otherThe Info object to compare with
Returns
true if the objects represent different I2C bus paths, false otherwise

◆ operator==()

bool Piduino::I2cDev::Info::operator== ( const Info other)

Equality comparison operator.

Parameters
otherThe Info object to compare with
Returns
true if both objects represent the same I2C bus path, false otherwise

◆ path()

const std::string & Piduino::I2cDev::Info::path ( ) const
inline

Gets the device path for this I2C bus.

Returns
A reference to the device path string (e.g., "/dev/i2c-0")

◆ setId()

void Piduino::I2cDev::Info::setId ( int  id)
inline

Sets the I2C bus ID and updates the corresponding device path.

Parameters
idThe new bus ID to set

◆ setPath()

bool Piduino::I2cDev::Info::setPath ( const std::string &  path)

Sets the device path and extracts the corresponding bus ID.

Parameters
pathThe device path to set
Returns
true if the path is valid and the ID was successfully extracted, false otherwise

Member Data Documentation

◆ _id

int Piduino::I2cDev::Info::_id
private

The I2C bus ID.

Definition at line 121 of file i2cdev.h.

◆ _path

std::string Piduino::I2cDev::Info::_path
private

The device path (e.g., "/dev/i2c-0")

Definition at line 123 of file i2cdev.h.

◆ MaxBuses

const int Piduino::I2cDev::Info::MaxBuses = 32
static

Maximum number of I2C buses supported by the system.

Definition at line 47 of file i2cdev.h.