Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

Commit 54537f3

Browse files
committed
differentiate RTU and TCP
1 parent 7176958 commit 54537f3

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/esp32ModbusRTU.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bool esp32ModbusRTU::readInputRegister(uint8_t slaveAddress, uint16_t address, u
5858
return true;
5959
}
6060

61-
void esp32ModbusRTU::onData(MBOnData handler) {
61+
void esp32ModbusRTU::onData(MBRTUOnData handler) {
6262
_onData = handler;
6363
}
6464

src/esp32ModbusRTU.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class esp32ModbusRTU {
5252
~esp32ModbusRTU();
5353
void begin();
5454
bool readInputRegister(uint8_t slaveAddress, uint16_t address, uint16_t byteCount);
55-
void onData(MBOnData handler);
55+
void onData(MBRTUOnData handler);
5656
void onError(MBOnError handler);
5757

5858
private:
@@ -67,6 +67,6 @@ class esp32ModbusRTU {
6767
int8_t _rtsPin;
6868
TaskHandle_t _task;
6969
QueueHandle_t _queue;
70-
MBOnData _onData;
70+
MBRTUOnData _onData;
7171
MBOnError _onError;
7272
};

src/esp32ModbusTypeDefs.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ enum MBError : uint8_t {
5757
COMM_ERROR = 0xE4 // general communication error
5858
};
5959

60-
typedef std::function<void(uint8_t, MBFunctionCode, uint8_t*, uint16_t)> MBOnData;
60+
typedef std::function<void(uint16_t, uint8_t, MBFunctionCode, uint8_t*, uint16_t)> MBTCPOnData;
61+
typedef std::function<void(uint8_t, MBFunctionCode, uint8_t*, uint16_t)> MBRTUOnData;
6162
typedef std::function<void(MBError)> MBOnError;
6263

6364
} // namespace esp32Modbus

0 commit comments

Comments
 (0)