Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: debevv/nanoMODBUS
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.19.0
Choose a base ref
...
head repository: debevv/nanoMODBUS
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Dec 12, 2024

  1. Copy the full SHA
    9b93660 View commit details
  2. Copy the full SHA
    a1705c0 View commit details

Commits on Dec 13, 2024

  1. Copy the full SHA
    c81ad17 View commit details

Commits on Dec 15, 2024

  1. Copy the full SHA
    20f1336 View commit details
  2. Copy the full SHA
    f9dfe53 View commit details
  3. Copy the full SHA
    18a90a0 View commit details
  4. Copy the full SHA
    42ba107 View commit details
  5. Copy the full SHA
    a1bf0bd View commit details
  6. Copy the full SHA
    0fdada9 View commit details
  7. Copy the full SHA
    63395b7 View commit details
  8. Copy the full SHA
    9b57f76 View commit details
  9. Copy the full SHA
    3c23889 View commit details
  10. Copy the full SHA
    c321e53 View commit details
  11. Copy the full SHA
    09f1f9d View commit details
  12. Copy the full SHA
    b8845df View commit details
  13. Copy the full SHA
    b45f07a View commit details
  14. Copy the full SHA
    048b9cf View commit details
  15. Copy the full SHA
    ff81c69 View commit details
  16. Copy the full SHA
    f8af123 View commit details
  17. adjusted unzip directory

    donghoonpark committed Dec 15, 2024
    Copy the full SHA
    d8da07b View commit details
  18. Copy the full SHA
    8dfcce3 View commit details
  19. Copy the full SHA
    d7bec6c View commit details
  20. Copy the full SHA
    c0b7cfc View commit details
  21. Merge pull request #78 from carlfriess/master

    Ignore invalid function codes sent to other servers
    debevv authored Dec 15, 2024
    Copy the full SHA
    4b1f629 View commit details
  22. Copy the full SHA
    cc28557 View commit details

Commits on Jan 15, 2025

  1. constS

    debevv committed Jan 15, 2025
    Copy the full SHA
    730cdaa View commit details
  2. Copy the full SHA
    d71ea71 View commit details

Commits on Mar 7, 2025

  1. Updated README

    debevv committed Mar 7, 2025
    Copy the full SHA
    7938f1e View commit details
  2. Update ci.yml

    debevv authored Mar 7, 2025
    Copy the full SHA
    a980f7f View commit details

Commits on Apr 27, 2025

  1. Copy the full SHA
    546040c View commit details

Commits on May 10, 2025

  1. coils: ability to configure number of supported coils

    No change to current default behaviour of allocating 2000 coils.
    However memory usage can be reduced by defining NMBS_MAX_COILS.
    ntfreak committed May 10, 2025
    Copy the full SHA
    d3ac9c1 View commit details

Commits on Jun 15, 2025

  1. optmized the following macros: nmbs_bitfield_read, nmbs_bitfield_set,…

    … nmbs_bitfield_unset, nmbs_bitfield_write
    harbi-eng committed Jun 15, 2025
    Copy the full SHA
    b5fde1c View commit details
  2. Copy the full SHA
    2d8fee9 View commit details
  3. Copy the full SHA
    99c59c2 View commit details

Commits on Jun 26, 2025

  1. Merge pull request #93 from harbi-eng/small-optmization

    optimized  nmbs_bitfield macros a little
    debevv authored Jun 26, 2025
    Copy the full SHA
    e390855 View commit details
  2. Copy the full SHA
    6605f91 View commit details
  3. Copy the full SHA
    979f66f View commit details
  4. Various fixes

    debevv committed Jun 26, 2025
    Copy the full SHA
    7df6f11 View commit details
Showing with 727 additions and 621 deletions.
  1. +1 −1 .clang-format
  2. +57 −7 .github/workflows/ci.yml
  3. +8 −2 .vscode/settings.json
  4. +31 −17 CMakeLists.txt
  5. +25 −2 README.md
  6. +3 −1 examples/stm32/CMakeLists.txt
  7. +69 −64 examples/stm32/FreeRTOSConfig.h
  8. +275 −278 examples/stm32/bsp/blackpill/blackpill.c
  9. +233 −233 examples/stm32/stm32f4xx_hal_conf.h
  10. +10 −9 nanomodbus.c
  11. +15 −7 nanomodbus.h
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignConsecutiveAssignments: false
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
64 changes: 57 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -9,18 +9,68 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: configure
run: |
cmake -S . -B build -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug
- name: build
run: |
mkdir build
cd build
cmake ..
make
./nanomodbus_tests
- name: Compile Arduino examples
cmake --build build --config Debug
- name: Compress Build Directory
run: tar -czf build.tar.gz build/
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: build
path: build.tar.gz
Embedded:
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v3
- name: Build Arduino examples
run: |
mkdir -p build
pushd build
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
popd
export PATH="build/bin:$PATH"
./examples/arduino/compile-examples.sh
- name: Install ARM dependencies
run: |
sudo apt update
sudo apt install -y cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential
- name: Build rp2040 examples
run: |
pushd examples/rp2040
git clone --depth=1 https://github.com/raspberrypi/pico-sdk.git
export PICO_SDK_PATH=$PWD/pico-sdk
cmake -S . -B build -DPICO_SDK_PATH=$PWD/pico-sdk
cmake --build build --config Debug
popd
- name: Build stm32 examples
run: |
pushd examples/stm32
cmake -S . -B build
cmake --build build --config Debug
popd
Test:
runs-on: ubuntu-latest
needs: Build # run after Build job
steps:
- uses: actions/checkout@v3
- name: Download Build Directory
uses: actions/download-artifact@v4
with:
name: build
- name: Extract Build Directory
run: |
mkdir -p build
tar -xzf build.tar.gz -C .
- name: List Build Files
run: ls -R .
- name: test
run: |
cd build
ctest
10 changes: 8 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
{
"cmake.configureOnOpen": true,
"cmake.configureArgs": [
"-DBUILD_TESTS=ON",
"-DBUILD_EXAMPLES=ON"
],
"cmake.copyCompileCommands": "${workspaceFolder}/compile_commands.json",
"C_Cpp.intelliSenseEngine": "disabled",
"clangd.path": "clangd",
"editor.formatOnSave": true,
"editor.rulers": [120],
"editor.rulers": [
120
],
"[c]": {
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"
},
"[cpp]": {
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"
},
}
}
48 changes: 31 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -8,20 +8,34 @@ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -g0")

include_directories(tests examples/linux .)

add_executable(nanomodbus_tests nanomodbus.c tests/nanomodbus_tests.c)
target_link_libraries(nanomodbus_tests pthread)

add_executable(server_disabled nanomodbus.c tests/server_disabled.c)
target_compile_definitions(server_disabled PUBLIC NMBS_SERVER_DISABLED)

add_executable(client_disabled nanomodbus.c tests/client_disabled.c)
target_compile_definitions(client_disabled PUBLIC NMBS_CLIENT_DISABLED)

add_executable(multi_server_rtu nanomodbus.c tests/multi_server_rtu.c)
target_compile_definitions(multi_server_rtu PUBLIC NMBS_DEBUG)
target_link_libraries(multi_server_rtu pthread)

add_custom_target(tests DEPENDS nanomodbus_tests server_disabled client_disabled multi_server_rtu)

add_executable(client-tcp nanomodbus.c examples/linux/client-tcp.c)
add_executable(server-tcp nanomodbus.c examples/linux/server-tcp.c)
# Define BUILD_SHARED_LIBS=ON to build a dynamic library instead
add_library(nanomodbus nanomodbus.c)
target_include_directories(nanomodbus PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

if (BUILD_EXAMPLES)
add_executable(client-tcp examples/linux/client-tcp.c)
target_link_libraries(client-tcp nanomodbus)
add_executable(server-tcp examples/linux/server-tcp.c)
target_link_libraries(server-tcp nanomodbus)
endif ()

if (BUILD_TESTS)
add_executable(nanomodbus_tests nanomodbus.c tests/nanomodbus_tests.c)
target_link_libraries(nanomodbus_tests pthread)

add_executable(server_disabled nanomodbus.c tests/server_disabled.c)
target_compile_definitions(server_disabled PUBLIC NMBS_SERVER_DISABLED)

add_executable(client_disabled nanomodbus.c tests/client_disabled.c)
target_compile_definitions(client_disabled PUBLIC NMBS_CLIENT_DISABLED)

add_executable(multi_server_rtu nanomodbus.c tests/multi_server_rtu.c)
target_compile_definitions(multi_server_rtu PUBLIC NMBS_DEBUG)
target_link_libraries(multi_server_rtu pthread)

enable_testing()
add_test(NAME test_general COMMAND $<TARGET_FILE:nanomodbus_tests>)
add_test(NAME test_server_disabled COMMAND $<TARGET_FILE:server_disabled>)
add_test(NAME test_client_disabled COMMAND $<TARGET_FILE:client_disabled>)
add_test(NAME test_multi_server_rtu COMMAND $<TARGET_FILE:multi_server_rtu>)
endif ()
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ resource-constrained systems like microcontrollers.
Its main features are:

- Compact size
- Only ~1500 lines of code
- Only ~2000 lines of code
- Client and server code can be disabled, if not needed
- No dynamic memory allocations
- Transports:
@@ -32,7 +32,7 @@ Its main features are:
- 43/14 (0x2B/0x0E) Read Device Identification
- Platform-agnostic
- Requires only C99 and its standard library
- Data transport read/write function are implemented by the user
- Data transport read/write functions are implemented by the user
- User-definable CRC function for better performance
- Broadcast requests and responses

@@ -96,8 +96,30 @@ int main(int argc, char* argv[]) {
## Installation
### Manual
Just copy `nanomodbus.c` and `nanomodbus.h` inside your application codebase.
### CMake project
nanomodbus supports library linking by using CMake.
```cmake
FetchContent_Declare(
nanomodbus
GIT_REPOSITORY https://github.com/debevv/nanoMODBUS
GIT_TAG master # or the version you want
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(nanomodbus)
#...
add_executable(your_program source_codes)
target_link_libraries(your_program nanomodbus)
```

## API reference

API reference is available in the repository's [GitHub Pages](https://debevv.github.io/nanoMODBUS/nanomodbus_8h.html).
@@ -165,4 +187,5 @@ Please refer to `examples/arduino/README.md` for more info about building and ru
- `NMBS_SERVER_READ_WRITE_REGISTERS_DISABLED`
- `NMBS_SERVER_READ_DEVICE_IDENTIFICATION_DISABLED`
- `NMBS_STRERROR_DISABLED` to disable the code that converts `nmbs_error`s to strings
- `NMBS_BITFIELD_MAX` to set the size of the `nmbs_bitfield` type, used to store coil values (default is `2000`)
- Debug prints about received and sent messages can be enabled by defining `NMBS_DEBUG`
4 changes: 3 additions & 1 deletion examples/stm32/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ FetchContent_MakeAvailable(wizchip)
FetchContent_Declare(
nanomodbus
GIT_REPOSITORY https://github.com/debevv/nanoMODBUS
GIT_TAG v1.18.1
GIT_TAG master
GIT_SHALLOW TRUE
)

@@ -67,6 +67,8 @@ endif ()
add_library(nanomodbus ${nanomodbus_SOURCE_DIR}/nanomodbus.c)
target_include_directories(nanomodbus PUBLIC ${nanomodbus_SOURCE_DIR})

# FetchContent_MakeAvailable(nanomodbus)

set(TARGET_NAMES modbus_rtu modbus_tcp)

foreach (TARGET_NAME ${TARGET_NAMES})
Loading