-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModbusInterface.h
More file actions
23 lines (22 loc) · 967 Bytes
/
ModbusInterface.h
File metadata and controls
23 lines (22 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef ModbusInterface_h
#define ModbusInterface_h
#include <Arduino.h>
#include <ArduinoRS485.h>
#include <ArduinoModbus.h>
class ModbusInterface {
private:
HardwareSerial& _serial; // Use a reference here, not a value
bool _verbose;
float _bitduration, _wordlen, _preDelayBR, _postDelayBR;
bool _inErrorState;
int _RS485config;
public:
ModbusInterface(HardwareSerial& serial, bool verbose);
void begin(int RS485baudrate, int RS485config);
bool writeHoldingRegisterValues(int address, int startingRegisterAddress, uint16_t *data, int dataLength);
bool writeHoldingRegisterValue(int address, int registerAddress, uint16_t dataByte);
bool readHoldingRegisterValues(int address, int startingRegisterAddress, int nValues, uint16_t *response);
bool readHoldingRegisterValue(int address, int registerAddress, uint16_t *response);
int getRS485config();
};
#endif