out_uartbridge.h
Go to the documentation of this file.
#pragma once
#include "options.h"
#ifdef UARTBRIDGE_ENABLE
#include <abstractout.h>
#include <item.h>
#include "itemCmd.h"
#include "utils.h"
#if defined(ESP32)
#define serialParamType uint32_t
#else
#define serialParamType uint16_t
#endif
#define SOURCE_PORT_A 5551
#define SOURCE_PORT_B 5552
#define MAX_PDU 64
#ifndef MODULE_UATRBRIDGE_UARTA
#define MODULE_UATRBRIDGE_UARTA Serial1
#endif
#ifndef MODULE_UATRBRIDGE_UARTB
#define MODULE_UATRBRIDGE_UARTB Serial2
#endif
#ifndef MODULE_UATRBRIDGE_UARTA_RX_PIN
#define MODULE_UATRBRIDGE_UARTA_RX_PIN 15
#endif
#ifndef MODULE_UATRBRIDGE_UARTA_TX_PIN
#define MODULE_UATRBRIDGE_UARTA_TX_PIN 2
#endif
#ifndef MODULE_UATRBRIDGE_UARTB_RX_PIN
#define MODULE_UATRBRIDGE_UARTB_RX_PIN -1
#endif
#ifndef MODULE_UATRBRIDGE_UARTB_TX_PIN
#define MODULE_UATRBRIDGE_UARTB_TX_PIN -1
#endif
class ubPersistent : public chPersistent {
public:
// int addr
int8_t driverStatus;
int baud;
serialParamType serialParam;
//uint16_t pollingInterval;
//uint32_t timestamp;
//aJsonObject * pollingRegisters;
//aJsonObject * pollingIrs;
//aJsonObject * parameters;
};
#define PDELAY 10
class out_UARTbridge : public abstractOut {
public:
out_UARTbridge(Item * _item):abstractOut(_item){store = (ubPersistent *) item->getPersistent();};
int Setup() override;
int Poll(short cause) override;
int Stop() override;
int Status() override;
int getChanType() override;
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true) override;
int getDefaultStorageType(){return ST_INT32;};
//int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL) override;
protected:
ubPersistent * store;
bool getConfig();
// int findRegister(int registerNum, int posInBuffer, int regType);
// void pollModbus(aJsonObject * reg, int regType);
};
#endif
abstractOut::Ctrl
virtual int Ctrl(itemCmd cmd, char *subItem=NULL, bool toExecute=true)=0
itemCmd.h
itemCmd
Definition: itemCmd.h:153
abstractCh::Stop
virtual int Stop()
Definition: abstractch.h:15
chPersistent
Definition: abstractout.h:7
ST_INT32
#define ST_INT32
Definition: itemCmd.h:96
serialParamType
#define serialParamType
Definition: utils.h:49
options.h
abstractOut
Definition: abstractout.h:8
utils.h
abstractOut::getDefaultStorageType
virtual int getDefaultStorageType()
Definition: abstractout.h:15
Item
Definition: item.h:104
abstractout.h
abstractOut::Setup
int Setup() override
Remove?? Now getChanType used instead.
Definition: abstractout.cpp:20
abstractCh::Poll
virtual int Poll(short cause)=0
abstractOut::getChanType
virtual int getChanType()
Definition: abstractout.h:14
abstractCh::Status
virtual int Status()
Definition: abstractch.h:16
item.h