Commit Graph

23 Commits

Author SHA1 Message Date
jonath.re@gmail.com
70c75cb2db Convert get_ and put_ to functions
This shaves off about 1 kB of flash usage from my client application.
It is also more type safe, which is nice.
2022-07-29 12:19:42 +02:00
Valerio De Benedetto
fd101fe77f Various fixes to NMBS_SERVER_* defines handling 2022-07-25 15:17:47 +02:00
Valerio De Benedetto
c12ba4b8a3 Merge branch 'callback-arg'
# Conflicts:
#	nanomodbus.c
#	nanomodbus.h
2022-07-25 12:59:40 +02:00
Valerio De Benedetto
5b685c9d97 Minor fixes 2022-07-25 12:47:11 +02:00
jonath.re@gmail.com
80fa8ef4ae Send platform argument to nmbs_callbacks
This is useful for the same reasons as the arg is useful in the platform callbacks.
2022-07-22 19:19:04 +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
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
Valerio De Benedetto
ca0dd3bab3 Merge remote-tracking branch 'jonathangjertsen/update-helper-names' 2022-06-11 16:16:19 +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
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
83fb04392b Fixes to integer types 2022-06-02 11:52:10 +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
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
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