Commit Graph

206 Commits

Author SHA1 Message Date
jonath.re@gmail.com
f926cd4a81 Add a CI workflow to build the code and run tests
Example output here: https://github.com/jonathangjertsen/nanoMODBUS/runs/7471676743

I'll try to build the Arduino examples as well, but this is a start
2022-07-22 18:10:39 +02:00
jonath.re@gmail.com
17aa0ca226 Support disabling individual server callbacks
This helps reduce code size for systems that do not implement the full
set of function codes supported by the library.
2022-07-22 17:14:32 +02:00
Valerio De Benedetto
10b9a0c13b NMBS_ERROR_INVALID_TCP_MBAP on invalid transaction ID 2022-06-26 11:10:29 +02:00
Valerio De Benedetto
037de71d9b Returning NMBS_ERROR_INVALID_UNIT_ID in case of invalid unit ID in response 2022-06-26 11:08:16 +02:00
Valerio De Benedetto
30c7ce3854 Moved nmbs_crc_calc() declaration 2022-06-26 09:26:07 +02:00
Valerio De Benedetto
4b613aa03d
Merge pull request #13 from jonathangjertsen/expose-crc
Expose the function that calculates CRC
2022-06-26 09:17:27 +02:00
Valerio De Benedetto
4f6c710835
Merge pull request #9 from jonathangjertsen/document-pointer-usage
Document that the platform configuration and callbacks can be discarded after initialization
2022-06-26 09:14:50 +02:00
jonath.re@gmail.com
f22b06082e Expose the function that calculates CRC
Having access to this function is useful in a variety of cases:

- hand-crafting PDUs for unit tests
- implementing extensions of the protocol
- reusing the code for other purposes (e.g. firmware integrity check)
2022-06-25 17:17:34 +02:00
Jonathan Reichelt Gjertsen
53a6a64f9b
Update wording in comment for nmbs_client_create and nmbs_server_create 2022-06-24 19:06:37 +02:00
Valerio De Benedetto
ca0dd3bab3 Merge remote-tracking branch 'jonathangjertsen/update-helper-names' 2022-06-11 16:16:19 +02:00
Valerio De Benedetto
bcf42e5f5f
Merge pull request #10 from jonathangjertsen/debug-newline
Make the debug output less likely to clash with output from the callbacks
2022-06-11 16:04:22 +02:00
Jonathan Reichelt Gjertsen
4393c4a8a0 Update names of helper functions to show whether they call send or put_1/put_2
I think this makes the code easier to read, since you can tell whether each
function call will actually `send` some bytes over the wire, or if it will
just `put` some bytes into the buffer.
2022-06-07 20:09:17 +02:00
Jonathan Reichelt Gjertsen
249c4f3919 Sometimes it's useful to turn NMBS_DEBUG on, but the output is a bit of a mess if the read/write callbacks also log to the same channel. Moving the DEBUG statements in recv_msg_footer and send_msg_footer to the start of the function makes the output a bit cleaner, although it's not perfect.
Example output before this change:

```
NMBS req -> fc 16   a 12326 q 2     b 4     regs 4660 43981 transmitted[13] = { f7, 10, 30, 26, 00, 02, 04, 12, 34, ab, cd, c2, 04, }

received[1] = { 0xf7, }
received[1] = { 0x10, }
NMBS res <- fc 16   received[4] = { 0x30, 0x26, 00, 0x2, }
a 12326     q 2received[2] = { 0xbb, 0x95, }

NMBS req -> fc 3    a 12326 q 2 transmitted[8] = { f7, 03, 30, 26, 00, 02, 3e, 56, }

received[1] = { 0xf7, }
received[1] = { 0x3, }
NMBS res <- fc 3    received[1] = { 0x4, }
b 4 received[4] = { 0x12, 0x34, 0xab, 0xcd, }
regs 466043981received[2] = { 0x96, 0x2f, }
```

after:

```
NMBS req -> fc 16   a 12326 q 2     b 4     regs 4660 43981
transmitted[13] = { f7, 10, 30, 26, 00, 02, 04, 12, 34, ab, cd, c2, 04, }
received[1] = { 0xf7, }
received[1] = { 0x10, }
NMBS res <- fc 16   received[4] = { 0x30, 0x26, 00, 0x2, }
a 12326     q 2
received[2] = { 0xbb, 0x95, }
NMBS req -> fc 3    a 12326 q 2
transmitted[8] = { f7, 03, 30, 26, 00, 02, 3e, 56, }
received[1] = { 0xf7, }
received[1] = { 0x3, }
NMBS res <- fc 3    received[1] = { 0x4, }
b 4 received[4] = { 0x12, 0x34, 0xab, 0xcd, }
regs 466043981
received[2] = { 0x96, 0x2f, }
```
2022-06-07 19:52:40 +02:00
Jonathan Reichelt Gjertsen
3a1170b925
Document that the platform configuration and callbacks can be discarded after initialization
`nmbs_client_create` accepts a `const nmbs_platform_conf* platform_conf` with configuration. Without reading the source code, it is not clear whether or not the object pointed to by `platform_conf` can be declared on the stack, or if it needs to be kept alive for the duration of the program (as would be the case if the implementation simply kept a pointer to the configuration instead of copying it by value). This PR adds an assurance that it is OK to discard the platform configuration after calling `nmbs_client_create`. Same idea for `nmbs_server_create`.
2022-06-07 19:29:04 +02:00
Valerio De Benedetto
6a3086c0f5 Updated CMakeLists.txt 2022-06-04 14:20:02 +02:00
Valerio De Benedetto
6e7fa6fdcc Updated README.md 2022-06-04 14:16:56 +02:00
Valerio De Benedetto
7045813f8b Fixes to arduino examples 2022-06-04 14:16:43 +02:00
Valerio De Benedetto
2a149a93ec Initial arduino examples 2022-06-02 22:49:30 +02:00
Valerio De Benedetto
494e1a385b Refactoring of examples 2022-06-02 22:48:54 +02:00
Valerio De Benedetto
53da24091b Added __AVR_ARCH__ endianness check 2022-06-02 22:39:30 +02:00
Valerio De Benedetto
7e6ce4f4fd Fixes 2022-06-02 21:58:21 +02:00
Valerio De Benedetto
432f6801f8 Updated readme 2022-06-02 11:59:51 +02:00
Valerio De Benedetto
a8bf7428cc Updated docstrings 2022-06-02 11:59:45 +02:00
Valerio De Benedetto
83fb04392b Fixes to integer types 2022-06-02 11:52:10 +02:00
Valerio De Benedetto
76f28fefb9 Updated examples 2022-06-02 11:10:42 +02:00
Valerio De Benedetto
7f811f2338 Updated tests 2022-06-02 10:53:43 +02:00
Valerio De Benedetto
b6fee48160 Switch to multibyte transport read/write funcs, removed sleep 2022-06-02 10:53:32 +02:00
Valerio De Benedetto
afcdae0ec8 Formatting 2022-05-12 19:29:51 +02:00
Valerio De Benedetto
271f689771 Added NMBS_ERROR_CRC and NMBS_ERROR_INVALID_TCP_MBAP nmbs_error 2022-05-12 19:28:50 +02:00
Valerio De Benedetto
3904a6c52f Swapped RTU CRC byte order 2022-05-12 18:59:21 +02:00
Valerio De Benedetto
452115ca89
Merge pull request #4 from jonathangjertsen/master
Support linking with C++ code
2022-05-11 12:20:14 +02:00
Jonathan Reichelt Gjertsen
8433fa047f
Support C++
Wrapping the header file in an `extern "C"` block prevents C++ compilers from mangling the function names.
2022-05-10 15:52:56 +02:00
Valerio De Benedetto
ac66269cda Better docs for platform functions 2022-04-30 13:52:13 +02:00
Valerio De Benedetto
9d2918b3bb Switch to MIT license 2022-04-30 13:03:36 +02:00
Valerio De Benedetto
8fc65aa2cf Fixed wrong size field in MBAP header 2022-04-26 00:05:13 +02:00
Valerio De Benedetto
5358abde7b Support to NMBS_CLIENT_DISABLED and NMBS_SERVER_DISABLED defines 2022-04-24 13:53:40 +02:00
Valerio De Benedetto
ee6dd565d4 Added license headers 2022-01-25 16:35:19 +01:00
Valerio De Benedetto
1d0321b285 Project rename 2022-01-25 00:37:54 +01:00
Valerio De Benedetto
352b03c7f6 Fixes to README 2022-01-25 00:18:55 +01:00
Valerio De Benedetto
b426a942c2 Fixes to README 2022-01-25 00:00:30 +01:00
Valerio De Benedetto
afe5b7df18 API documentation 2022-01-24 22:09:54 +01:00
Valerio De Benedetto
b19cd6cb45 Added LICENSE 2022-01-24 20:18:21 +01:00
Valerio De Benedetto
1461afbc0c README 2022-01-24 20:16:26 +01:00
Valerio De Benedetto
18c033000c Fixes 2022-01-24 20:16:20 +01:00
Valerio De Benedetto
d25e462e69 Debug prints 2022-01-24 19:01:08 +01:00
Valerio De Benedetto
07b4440096 Examples, fixes 2022-01-24 16:46:42 +01:00
Valerio De Benedetto
d9d66989d7 Byte spacing tests 2022-01-22 12:18:32 +01:00
Valerio De Benedetto
13cd7c74b6 Additional tests 2022-01-22 11:34:47 +01:00
Valerio De Benedetto
c064e47368 FC1 and FC2 tests 2022-01-21 15:50:03 +01:00
Valerio De Benedetto
1951b1d923 Minimum functionality 2022-01-20 20:03:38 +01:00