Instrument Neutral Distributed Interface INDI 2.2.5
connectioni2c.h
Go to the documentation of this file.
1/*
2 I2C Connection Plugin
3 Copyright (C) 2025 Jasem Mutlaq ([email protected])
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19*/
20
21#pragma once
22
23#include "connectioninterface.h"
24#include "indipropertytext.h"
25#include <string>
26#include <stdint.h>
27
28namespace Connection
29{
30
36class I2C : public Interface
37{
38 public:
44
45
46 I2C(INDI::DefaultDevice *dev, IPerm permission = IP_RW);
47 virtual ~I2C();
48
49 virtual bool Connect() override;
50 virtual bool Disconnect() override;
51
52 virtual void Activated() override;
53 virtual void Deactivated() override;
54
55 virtual std::string name() override
56 {
57 return "CONNECTION_I2C";
58 }
59
60 virtual std::string label() override
61 {
62 return "I2C";
63 }
64
68 virtual const char *busPath();
69
73 virtual uint8_t address();
74
80 void setDefaultBusPath(const char *path);
81
87 void setDefaultAddress(uint8_t addr);
88
93 int getPortFD() const
94 {
95 return PortFD;
96 }
97
98 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
99 virtual bool saveConfigItems(FILE *fp) override;
100
101 protected:
109 virtual bool Connect(const char *busPath, uint8_t address);
110
111 virtual bool processHandshake();
112
114
115 int PortFD = -1;
116
118
119 std::string m_ConfigBusPath;
121};
122
123}
The I2C class manages connection with I2C devices on Linux systems. I2C communication is commonly use...
std::string m_ConfigBusPath
virtual void Activated() override
Activated Function called by the framework when the plugin is activated (i.e. selected by the user)....
int getPortFD() const
void setDefaultAddress(uint8_t addr)
setDefaultAddress Set default I2C address. The default address is 0x28 unless otherwise changed by th...
INDI::PropertyText I2CConnectionTP
virtual const char * busPath()
void setDefaultBusPath(const char *path)
setDefaultBusPath Set default I2C bus path. Call this function in initProperties() of your driver if ...
virtual bool Connect() override
Connect Connect to device via the implemented communication medium. Do not perform any handshakes.
virtual bool processHandshake()
virtual uint8_t address()
virtual void Deactivated() override
Deactivated Function called by the framework when the plugin is deactivated. It is usually used to de...
virtual std::string name() override
virtual bool Disconnect() override
Disconnect Disconnect from device.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
virtual std::string label() override
virtual bool saveConfigItems(FILE *fp) override
The Interface class is the base class for all INDI connection plugins.
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
IPerm
Permission hint, with respect to client.
Definition indiapi.h:181
@ IP_RW
Definition indiapi.h:184
Combines all INDI Connection Plugins. Each INDI connection plugin is responsible of managing communic...
Definition arduino_st4.h:34