From 6370523f2425d354cd9e4417e7b8c5e4c5124994 Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 21 Dec 2020 05:38:26 -0800 Subject: [PATCH 1/4] Add CI workflow to compile example sketches On every push and pull request, do a "smoke test" by compiling the example sketches of the library for the given list of Arduino boards. --- .github/workflows/compile-examples.yml | 80 ++++++++++++++++++++++++++ README.adoc | 6 ++ 2 files changed, 86 insertions(+) create mode 100644 .github/workflows/compile-examples.yml diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml new file mode 100644 index 0000000..8645809 --- /dev/null +++ b/.github/workflows/compile-examples.yml @@ -0,0 +1,80 @@ +name: Compile Examples + +on: + pull_request: + paths: + - ".github/workflows/compile-examples.yml" + - "examples/**" + - "src/**" + push: + paths: + - ".github/workflows/compile-examples.yml" + - "examples/**" + - "src/**" + schedule: + # run every Tuesday at 3 AM UTC to catch breakage caused by changes to external dependencies (libraries, platforms) + - cron: "0 3 * * 2" + # See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#workflow_dispatch + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + env: + # Libraries to install for all boards + UNIVERSAL_LIBRARIES: | + # Install the ArduinoModbus library from the local path + - source-path: ./ + - name: ArduinoRS485 + UNIVERSAL_SKETCH_PATHS: | + - examples/RTU + + strategy: + fail-fast: false + + matrix: + board: + - fqbn: arduino:avr:nano + nina: false + - fqbn: arduino:avr:leonardo + nina: false + - fqbn: arduino:megaavr:uno2018:mode=off + nina: true + - fqbn: arduino:samd:mkrwifi1010 + nina: true + - fqbn: arduino:mbed:nano33ble + nina: false + - fqbn: arduino:mbed:envie_m7 + nina: false + + # Make board type-specific customizations to the matrix jobs + include: + - board: + # Boards with NINA-W102 module + nina: true + # Install these libraries in addition to the ones defined by env.UNIVERSAL_LIBRARIES + nina-libraries: | + - name: WiFiNINA + # Compile these sketches in addition to the ones defined by env.UNIVERSAL_SKETCH_PATHS + nina-sketch-paths: | + - examples/TCP + - board: + nina: false + nina-libraries: "" + nina-sketch-paths: "" + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Compile examples + uses: arduino/compile-sketches@main + with: + fqbn: ${{ matrix.board.fqbn }} + libraries: | + ${{ env.UNIVERSAL_LIBRARIES }} + ${{ matrix.nina-libraries }} + sketch-paths: | + ${{ env.UNIVERSAL_SKETCH_PATHS }} + ${{ matrix.nina-sketch-paths }} diff --git a/README.adoc b/README.adoc index 79fab17..1516a37 100644 --- a/README.adoc +++ b/README.adoc @@ -1,5 +1,11 @@ +// Define the repository information in these attributes +:repository-owner: arduino-libraries +:repository-name: ArduinoModbus + = Modbus Library for Arduino = +image:https://github.com/{repository-owner}/{repository-name}/workflows/Compile%20Examples/badge.svg["Compile Examples Status", link="https://github.com/{repository-owner}/{repository-name}/actions?workflow=Compile+Examples"] + Use http://www.modbus.org/[Modbus] with your Arduino. Using TCP or RS485 shields, like the MKR 485 Shield. This library depends on the ArduinoRS485 library. From 28ca5a3d30d5cd98b392dd72833afd5d7296b56c Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 21 Dec 2020 05:52:34 -0800 Subject: [PATCH 2/4] Report changes in memory usage that would result from merging a PR On creation or commit to a pull request, a report of the resulting change in memory usage of the examples will be commented to the PR thread. --- .github/workflows/compile-examples.yml | 9 +++++++++ .github/workflows/report-size-deltas.yml | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 .github/workflows/report-size-deltas.yml diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 8645809..36e233a 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -22,6 +22,7 @@ jobs: runs-on: ubuntu-latest env: + SKETCHES_REPORTS_PATH: sketches-reports # Libraries to install for all boards UNIVERSAL_LIBRARIES: | # Install the ArduinoModbus library from the local path @@ -78,3 +79,11 @@ jobs: sketch-paths: | ${{ env.UNIVERSAL_SKETCH_PATHS }} ${{ matrix.nina-sketch-paths }} + enable-deltas-report: true + sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} + + - name: Save memory usage change report as artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ env.SKETCHES_REPORTS_PATH }} + path: ${{ env.SKETCHES_REPORTS_PATH }} diff --git a/.github/workflows/report-size-deltas.yml b/.github/workflows/report-size-deltas.yml new file mode 100644 index 0000000..fa5a566 --- /dev/null +++ b/.github/workflows/report-size-deltas.yml @@ -0,0 +1,18 @@ +name: Report Size Deltas + +on: + schedule: + - cron: "*/5 * * * *" + # See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#workflow_dispatch + workflow_dispatch: + +jobs: + report: + runs-on: ubuntu-latest + + steps: + - name: Comment size deltas reports to PRs + uses: arduino/report-size-deltas@main + with: + # The name of the workflow artifact created by the "Compile Examples" workflow + sketches-reports-source: sketches-reports From af78cf6555f2260eec5a94a8aeb0e56ae9fadecf Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 21 Dec 2020 05:53:26 -0800 Subject: [PATCH 3/4] Add CI workflow to check for commonly misspelled words In the event of a false positive, the problematic word should be added, in all lowercase, to extras/codespell-ignore-words-list.txt, after which it will be ignored by the action. --- .github/workflows/spell-check.yml | 26 ++++++++++++++++++++++++++ README.adoc | 1 + extras/codespell-ignore-words-list.txt | 0 3 files changed, 27 insertions(+) create mode 100644 .github/workflows/spell-check.yml create mode 100644 extras/codespell-ignore-words-list.txt diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml new file mode 100644 index 0000000..cdbf4f6 --- /dev/null +++ b/.github/workflows/spell-check.yml @@ -0,0 +1,26 @@ +name: Spell Check + +on: + pull_request: + push: + schedule: + # run every Tuesday at 3 AM UTC + - cron: "0 3 * * 2" + +jobs: + spellcheck: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + # See: https://github.com/codespell-project/actions-codespell/blob/master/README.md + - name: Spell check + uses: codespell-project/actions-codespell@master + with: + check_filenames: true + check_hidden: true + # In the event of a false positive, add the word in all lower case to this file: + ignore_words_file: extras/codespell-ignore-words-list.txt + skip: ./.git,./src/libmodbus diff --git a/README.adoc b/README.adoc index 1516a37..6ea2f54 100644 --- a/README.adoc +++ b/README.adoc @@ -5,6 +5,7 @@ = Modbus Library for Arduino = image:https://github.com/{repository-owner}/{repository-name}/workflows/Compile%20Examples/badge.svg["Compile Examples Status", link="https://github.com/{repository-owner}/{repository-name}/actions?workflow=Compile+Examples"] +image:https://github.com/{repository-owner}/{repository-name}/workflows/Spell%20Check/badge.svg["Spell Check Status", link="https://github.com/{repository-owner}/{repository-name}/actions?workflow=Spell+Check"] Use http://www.modbus.org/[Modbus] with your Arduino. diff --git a/extras/codespell-ignore-words-list.txt b/extras/codespell-ignore-words-list.txt new file mode 100644 index 0000000..e69de29 From ffb45a69c3fa2ca6f8472b9beb3c55761d9e815d Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 21 Dec 2020 06:08:22 -0800 Subject: [PATCH 4/4] Fix typos in comments --- .../ModbusRTUClientKitchenSink.ino | 5 ++--- .../ModbusRTUServerKitchenSink.ino | 4 ++-- examples/RTU/ModbusRTUServerLED/ModbusRTUServerLED.ino | 2 +- .../ModbusRTUTemperatureSensor.ino | 2 +- .../TCP/WiFiModbusClientToggle/WiFiModbusClientToggle.ino | 2 +- examples/TCP/WiFiModbusServerLED/WiFiModbusServerLED.ino | 2 +- src/ModbusClient.h | 2 +- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/RTU/ModbusRTUClientKitchenSink/ModbusRTUClientKitchenSink.ino b/examples/RTU/ModbusRTUClientKitchenSink/ModbusRTUClientKitchenSink.ino index 1fa14ec..397a382 100644 --- a/examples/RTU/ModbusRTUClientKitchenSink/ModbusRTUClientKitchenSink.ino +++ b/examples/RTU/ModbusRTUClientKitchenSink/ModbusRTUClientKitchenSink.ino @@ -1,7 +1,7 @@ /* Modbus RTU Client Kitchen Sink - This sketch creates a Modbus RTU Client and demostrates + This sketch creates a Modbus RTU Client and demonstrates how to use various Modbus Client APIs. Circuit: @@ -164,7 +164,7 @@ void readHoldingRegisterValues() { void readInputRegisterValues() { Serial.print("Reading input register values ... "); - // read 10 dsicrete input values from (slave) id 42, + // read 10 discrete input values from (slave) id 42, if (!ModbusRTUClient.requestFrom(42, INPUT_REGISTERS, 0x00, 10)) { Serial.print("failed! "); Serial.println(ModbusRTUClient.lastError()); @@ -181,4 +181,3 @@ void readInputRegisterValues() { // Alternatively, to read a single Input Register value use: // ModbusRTUClient.inputRegisterRead(...) } - diff --git a/examples/RTU/ModbusRTUServerKitchenSink/ModbusRTUServerKitchenSink.ino b/examples/RTU/ModbusRTUServerKitchenSink/ModbusRTUServerKitchenSink.ino index 8501aa3..832f05b 100644 --- a/examples/RTU/ModbusRTUServerKitchenSink/ModbusRTUServerKitchenSink.ino +++ b/examples/RTU/ModbusRTUServerKitchenSink/ModbusRTUServerKitchenSink.ino @@ -1,7 +1,7 @@ /* Modbus RTU Server Kitchen Sink - This sketch creates a Modbus RTU Server and demostrates + This sketch creates a Modbus RTU Server and demonstrates how to use various Modbus Server APIs. Circuit: @@ -62,7 +62,7 @@ void loop() { ModbusRTUServer.discreteInputWrite(i, coilValue); } - // map the holiding register values to the input register values + // map the holding register values to the input register values for (int i = 0; i < numHoldingRegisters; i++) { long holdingRegisterValue = ModbusRTUServer.holdingRegisterRead(i); diff --git a/examples/RTU/ModbusRTUServerLED/ModbusRTUServerLED.ino b/examples/RTU/ModbusRTUServerLED/ModbusRTUServerLED.ino index bf0b1cd..d8adca9 100644 --- a/examples/RTU/ModbusRTUServerLED/ModbusRTUServerLED.ino +++ b/examples/RTU/ModbusRTUServerLED/ModbusRTUServerLED.ino @@ -53,7 +53,7 @@ void loop() { // coil value set, turn LED on digitalWrite(ledPin, HIGH); } else { - // coild value clear, turn LED off + // coil value clear, turn LED off digitalWrite(ledPin, LOW); } } diff --git a/examples/RTU/ModbusRTUTemperatureSensor/ModbusRTUTemperatureSensor.ino b/examples/RTU/ModbusRTUTemperatureSensor/ModbusRTUTemperatureSensor.ino index dceb1dd..323e55a 100644 --- a/examples/RTU/ModbusRTUTemperatureSensor/ModbusRTUTemperatureSensor.ino +++ b/examples/RTU/ModbusRTUTemperatureSensor/ModbusRTUTemperatureSensor.ino @@ -1,5 +1,5 @@ /* - Modbus RTU Temeperature Sensor + Modbus RTU Temperature Sensor This sketch shows you how to interact with a Modbus RTU temperature and humidity sensor. It reads the temperature and humidity values every 5 seconds and outputs them to the diff --git a/examples/TCP/WiFiModbusClientToggle/WiFiModbusClientToggle.ino b/examples/TCP/WiFiModbusClientToggle/WiFiModbusClientToggle.ino index 98c29db..0322c89 100644 --- a/examples/TCP/WiFiModbusClientToggle/WiFiModbusClientToggle.ino +++ b/examples/TCP/WiFiModbusClientToggle/WiFiModbusClientToggle.ino @@ -40,7 +40,7 @@ void setup() { Serial.println("Modbus TCP Client Toggle"); - // attempt to connect to Wifi network: + // attempt to connect to WiFi network: while (status != WL_CONNECTED) { Serial.print("Attempting to connect to SSID: "); Serial.println(ssid); diff --git a/examples/TCP/WiFiModbusServerLED/WiFiModbusServerLED.ino b/examples/TCP/WiFiModbusServerLED/WiFiModbusServerLED.ino index c4c23fe..60276c0 100644 --- a/examples/TCP/WiFiModbusServerLED/WiFiModbusServerLED.ino +++ b/examples/TCP/WiFiModbusServerLED/WiFiModbusServerLED.ino @@ -41,7 +41,7 @@ void setup() { Serial.println("Modbus TCP Server LED"); - // attempt to connect to Wifi network: + // attempt to connect to WiFi network: while (status != WL_CONNECTED) { Serial.print("Attempting to connect to SSID: "); Serial.println(ssid); diff --git a/src/ModbusClient.h b/src/ModbusClient.h index 72ee159..468e07a 100644 --- a/src/ModbusClient.h +++ b/src/ModbusClient.h @@ -65,7 +65,7 @@ class ModbusClient { * @param id (slave) id of target, defaults to 0x00 if not specified * @param address start address to use for operation * - * @return holiding register value on success, -1 on failure. + * @return holding register value on success, -1 on failure. */ long holdingRegisterRead(int address); long holdingRegisterRead(int id, int address);