DUDS
Distributed Update of Data from Something
duds::hardware::interface::I2c Class Referenceabstract

A basic I2C interface. More...

#include <I2c.hpp>

Inheritance diagram for duds::hardware::interface::I2c:
Collaboration diagram for duds::hardware::interface::I2c:

Public Member Functions

virtual int address () const =0
 Returns the address of the device that this object will attempt to communicate with. More...
 
virtual void converse (Conversation &conv)=0
 Conducts I2C communication with a device. More...
 
- Public Member Functions inherited from duds::hardware::interface::Conversationalist
virtual ~Conversationalist ()=0
 Allow proper destruction using a Conversationalist pointer. More...
 

Detailed Description

A basic I2C interface.

Could use some convenience functions.

Author
Jeff Jackowski

Definition at line 22 of file I2c.hpp.

Member Function Documentation

◆ address()

virtual int duds::hardware::interface::I2c::address ( ) const
pure virtual

Returns the address of the device that this object will attempt to communicate with.

Implemented in duds::hardware::interface::linux::DevI2c.

◆ converse()

virtual void duds::hardware::interface::I2c::converse ( Conversation conv)
pure virtual

Conducts I2C communication with a device.

The MpfVarlen flag of ConversationPart may be optionally honored. The part is expected to have an adequately long buffer allocated before this call. Implementations should throw I2cErrorPartLength if the buffer is inadequate. The I2C standard, as published by NXP, does not seem to address incoming messages of varying length with the length sent by the device (slave), so there doesn't seem to be a good general minimum. Linux requires more than 32 bytes.

The MpfBreak flag of ConversationPart objects should be honored by causing a stop condition, but it is implementation defined as to whether the bus may be used by other threads or processes before continuing with this conversation. A multi-master bus will always allow another master to start communicating after a stop condition. Conversation parts between set MpfBreak flags should be sent with a single stop condition.

Parameters
convThe conversation to have with the device on the other end.

The exceptions listed below may not include some that are specific to an implementation, but those exception classes should derive from I2cError.

Exceptions
I2cErrorConversationLengthThe conversation has too many parts for the implementation to handle.
I2cErrorPartLengthA variable length input part had a buffer that was too short.
I2cErrorBusyThe bus was in use for an inordinate length of time. This is not caused by scheduling on the same host computer. It can be caused by another I2C master on a mulit-master bus.
I2cErrorNoDeviceThe device did not respond to its address.
I2cErrorUnsupportedAn operation is unsupported by the master.
I2cErrorProtocolData from the device does not conform to the I2C protocol.
I2cErrorTimeoutThe operation took too long resulting in a bus timeout.
I2cErrorA general error that doesn't fit one of the other exceptions.

Implements duds::hardware::interface::Conversationalist.

Implemented in duds::hardware::interface::linux::DevI2c.


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