The I2C class manages connection with I2C devices on Linux systems. I2C communication is commonly used for sensors and other embedded devices. The default I2C bus is /dev/i2c-1 and default address is 0x28. After I2C connection is established successfully, a handshake is performed to verify device communication.
More...
#include <connectioni2c.h>
|
| | I2C (INDI::DefaultDevice *dev, IPerm permission=IP_RW) |
| |
| virtual | ~I2C () |
| |
| virtual bool | Connect () override |
| | Connect Connect to device via the implemented communication medium. Do not perform any handshakes.
|
| |
| virtual bool | Disconnect () override |
| | Disconnect Disconnect from device.
|
| |
| virtual void | Activated () override |
| | Activated Function called by the framework when the plugin is activated (i.e. selected by the user). It is usually used to define properties pertaining to the specific plugin functionalities.
|
| |
| virtual void | Deactivated () override |
| | Deactivated Function called by the framework when the plugin is deactivated. It is usually used to delete properties by were defined previously since the plugin is no longer active.
|
| |
| virtual std::string | name () override |
| |
| virtual std::string | label () override |
| |
| virtual const char * | busPath () |
| |
| virtual uint8_t | address () |
| |
| void | setDefaultBusPath (const char *path) |
| | setDefaultBusPath Set default I2C bus path. Call this function in initProperties() of your driver if you want to change default bus path.
|
| |
| void | setDefaultAddress (uint8_t addr) |
| | setDefaultAddress Set default I2C address. The default address is 0x28 unless otherwise changed by this function. Call this function in initProperties() of your driver.
|
| |
| int | getPortFD () const |
| |
| virtual bool | ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n) override |
| |
| virtual bool | saveConfigItems (FILE *fp) override |
| |
| virtual Type | type () |
| | type Return connection type
|
| |
| virtual bool | ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n) |
| |
| virtual bool | ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n) |
| |
| virtual bool | ISNewBLOB (const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n) |
| |
| void | registerHandshake (std::function< bool()> callback) |
| | registerHandshake Register a handshake function to be called once the initial connection to the device is established.
|
| |
The I2C class manages connection with I2C devices on Linux systems. I2C communication is commonly used for sensors and other embedded devices. The default I2C bus is /dev/i2c-1 and default address is 0x28. After I2C connection is established successfully, a handshake is performed to verify device communication.
Definition at line 36 of file connectioni2c.h.
◆ I2CConnectionText
◆ I2C()
◆ ~I2C()
| Connection::I2C::~I2C |
( |
| ) |
|
|
virtual |
◆ Activated()
| void Connection::I2C::Activated |
( |
| ) |
|
|
overridevirtual |
Activated Function called by the framework when the plugin is activated (i.e. selected by the user). It is usually used to define properties pertaining to the specific plugin functionalities.
Implements Connection::Interface.
Definition at line 171 of file connectioni2c.cpp.
◆ address()
| uint8_t Connection::I2C::address |
( |
| ) |
|
|
virtual |
◆ busPath()
| const char * Connection::I2C::busPath |
( |
| ) |
|
|
virtual |
◆ Connect() [1/2]
| bool Connection::I2C::Connect |
( |
| ) |
|
|
overridevirtual |
Connect Connect to device via the implemented communication medium. Do not perform any handshakes.
- Returns
- True if successful, false otherwise.
Implements Connection::Interface.
Definition at line 84 of file connectioni2c.cpp.
◆ Connect() [2/2]
| bool Connection::I2C::Connect |
( |
const char * |
busPath, |
|
|
uint8_t |
address |
|
) |
| |
|
protectedvirtual |
Connect to I2C device.
- Parameters
-
| busPath | I2C bus path to connect to. |
| address | I2C device address |
- Returns
- True if connection is successful, false otherwise
- Warning
- Do not call this function directly, it is called by Connection::I2C Connect() function.
Definition at line 125 of file connectioni2c.cpp.
◆ Deactivated()
| void Connection::I2C::Deactivated |
( |
| ) |
|
|
overridevirtual |
Deactivated Function called by the framework when the plugin is deactivated. It is usually used to delete properties by were defined previously since the plugin is no longer active.
Implements Connection::Interface.
Definition at line 176 of file connectioni2c.cpp.
◆ Disconnect()
| bool Connection::I2C::Disconnect |
( |
| ) |
|
|
overridevirtual |
◆ getPortFD()
| int Connection::I2C::getPortFD |
( |
| ) |
const |
|
inline |
- Returns
- Return I2C file descriptor. If connection is successful, I2CFD is a positive integer otherwise it is set to -1
Definition at line 93 of file connectioni2c.h.
◆ ISNewText()
| bool Connection::I2C::ISNewText |
( |
const char * |
dev, |
|
|
const char * |
name, |
|
|
char * |
texts[], |
|
|
char * |
names[], |
|
|
int |
n |
|
) |
| |
|
overridevirtual |
◆ label()
| virtual std::string Connection::I2C::label |
( |
| ) |
|
|
inlineoverridevirtual |
◆ name()
| virtual std::string Connection::I2C::name |
( |
| ) |
|
|
inlineoverridevirtual |
◆ processHandshake()
| bool Connection::I2C::processHandshake |
( |
| ) |
|
|
protectedvirtual |
◆ saveConfigItems()
| bool Connection::I2C::saveConfigItems |
( |
FILE * |
fp | ) |
|
|
overridevirtual |
◆ setDefaultAddress()
| void Connection::I2C::setDefaultAddress |
( |
uint8_t |
addr | ) |
|
setDefaultAddress Set default I2C address. The default address is 0x28 unless otherwise changed by this function. Call this function in initProperties() of your driver.
- Parameters
-
Definition at line 205 of file connectioni2c.cpp.
◆ setDefaultBusPath()
| void Connection::I2C::setDefaultBusPath |
( |
const char * |
path | ) |
|
setDefaultBusPath Set default I2C bus path. Call this function in initProperties() of your driver if you want to change default bus path.
- Parameters
-
| path | Name of desired default bus path |
Definition at line 196 of file connectioni2c.cpp.
◆ I2CConnectionTP
◆ m_ConfigAddress
| int Connection::I2C::m_ConfigAddress {-1} |
|
protected |
◆ m_ConfigBusPath
| std::string Connection::I2C::m_ConfigBusPath |
|
protected |
◆ m_Permission
◆ PortFD
| int Connection::I2C::PortFD = -1 |
|
protected |
The documentation for this class was generated from the following files: