Skip to content

Commit 78ae616

Browse files
authored
fix modbus errors by upgrading to eModbus 1.7.0 (#9)
* switch eModbus to StreamRTU branch * update to eModbus 1.7.0 * cleanup * update actions * https://docs.platformio.org/en/stable/integration/ci/github-actions.html
1 parent a4d5cae commit 78ae616

File tree

3 files changed

+24
-29
lines changed

3 files changed

+24
-29
lines changed

.github/workflows/main.yml

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,23 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: actions/checkout@v2
12-
- name: Cache pip
13-
uses: actions/cache@v2
14-
with:
15-
path: ~/.cache/pip
16-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
17-
restore-keys: |
18-
${{ runner.os }}-pip-
19-
- name: Cache PlatformIO
20-
uses: actions/cache@v2
21-
with:
22-
path: ~/.platformio
23-
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
24-
- name: Set up Python
25-
uses: actions/setup-python@v2
26-
- name: Install PlatformIO
27-
run: |
28-
python -m pip install --upgrade pip
29-
pip install --upgrade platformio
30-
- name: Run PlatformIO
31-
run: pio run -e esp32release
32-
- name: Upload artifacts
33-
uses: actions/upload-artifact@v3
34-
with:
35-
name: image
36-
path: .pio/build/esp32release/firmware.bin
11+
- uses: actions/checkout@v3
12+
- uses: actions/cache@v3
13+
with:
14+
path: |
15+
~/.cache/pip
16+
~/.platformio/.cache
17+
key: ${{ runner.os }}-pio
18+
- uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.9'
21+
- name: Install PlatformIO Core
22+
run: pip install --upgrade platformio
23+
24+
- name: Build PlatformIO Project
25+
run: pio run -e esp32release
26+
- name: Upload artifacts
27+
uses: actions/upload-artifact@v3
28+
with:
29+
name: image
30+
path: .pio/build/esp32release/firmware.bin

platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
lib_deps =
1818
https://github.com/tzapu/WiFiManager.git
1919
https://github.com/me-no-dev/ESPAsyncWebServer.git
20-
eModbus
20+
miq19/eModbus @ ^1.7.0
2121
monitor_speed = 115200
2222

2323

src/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ void setup() {
3131
dbgln("[wifi] finished");
3232
dbgln("[modbus] start");
3333

34+
RTUutils::prepareHardwareSerial(modbusSerial);
3435
#if defined(RX_PIN) && defined(TX_PIN)
3536
// use rx and tx-pins if defined in platformio.ini
3637
modbusSerial.begin(config.getModbusBaudRate(), config.getModbusConfig(), RX_PIN, TX_PIN );
@@ -40,9 +41,9 @@ void setup() {
4041
modbusSerial.begin(config.getModbusBaudRate(), config.getModbusConfig());
4142
#endif
4243

43-
MBclient = new ModbusClientRTU(modbusSerial, config.getModbusRtsPin());
44+
MBclient = new ModbusClientRTU(config.getModbusRtsPin());
4445
MBclient->setTimeout(1000);
45-
MBclient->begin();
46+
MBclient->begin(modbusSerial);
4647
for (uint8_t i = 1; i < 248; i++)
4748
{
4849
MBbridge.attachServer(i, i, ANY_FUNCTION_CODE, MBclient);

0 commit comments

Comments
 (0)