-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathModbusRelay.h
More file actions
47 lines (36 loc) · 1.07 KB
/
ModbusRelay.h
File metadata and controls
47 lines (36 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
#include <Arduino.h>
#ifdef CONTROLLINO_MAXI
#include <Ethernet.h>
#else
#include <EthernetV2_0.h>
#endif
#include "ModbusSerial.h"
class ModbusRelay : public ModbusSerial {
private:
unsigned int ModbusTimeout_ms; // Modbus timeout for Serial transactions in ms
bool _SerialInProgress; // True when a transaction is in progress over the serial port*
unsigned long _timeoutTransaction;
unsigned long _timeoutFrame;
byte _MBAP[7];
byte *_frame;
byte _len;
byte _tcp_len;
EthernetClient client;
byte _fc; // Function code of on-going transaction
byte _rxid; // Received slaveID
bool RX();
short stats_transaction;
short stats_crc_error;
short stats_timeout;
short stats_short_frame;
public:
ModbusRelay();
typedef enum { off, tx, rx } txrx_mode;
void(*_switch_txrx)(txrx_mode);
void configRelay(HardwareSerial * port, long baud, u_int format, void(*_switch_txrx)(txrx_mode));
void TX(EthernetClient client, byte MBAP[], byte * frame, byte len);
bool pollSerial();
void pollTCP();
String DumpStats();
};