DigitalIO driver with dynamic channel count

This commit is contained in:
Emanuele Trabattoni
2025-07-12 13:45:00 +02:00
parent 1955b8cb39
commit ef7b9506b6
8 changed files with 335 additions and 38 deletions

37
src/remoteIO.h Normal file
View File

@@ -0,0 +1,37 @@
#pragma once
#include <DebugLog.h>
#include <RS485_Driver.h>
class remoteIO
{
public:
typedef enum {CH1, CH2, CH3, CH4, CH5, CH6, CH7, CH8, CH_MAX} channel_t;
private:
const uint16_t REG_VERSION = 0x8000;
const uint16_t REG_COILS = 0x0000;
const uint16_t REG_INPUT = 0x0000;
const uint16_t REG_ALLCOILS = 0x00FF;
public:
remoteIO(const uint8_t address, drivers::MODBUS &bus);
~remoteIO();
const bool setOut(const channel_t ch, const bool value);
const bool toggleOut(const channel_t ch);
const bool setOutPort(const std::vector<bool> values);
const bool getOut(const channel_t ch, bool &value);
const bool getOutPort(std::vector<bool> &values);
const bool getIn(const channel_t input, bool &value);
const bool getInPort(std::vector<bool> &values);
void resetAll(const bool value);
private:
bool m_initialized;
drivers::MODBUS &m_bus;
const uint8_t m_address;
};