diff --git a/NEWS b/NEWS index 7f1cf59..58988a9 100644 --- a/NEWS +++ b/NEWS @@ -15,10 +15,12 @@ libmodbus 2.2.0 (2009-XX-01) - Fix #378981 - CRC error on RTU response doesn't return negative value Reported by Henrik Munktell. - Fix report slave ID request - Patch (bzr) provided by Paul Fertser . + Patch (bzr) provided by Paul Fertser. - Fix #425604 - Conditional jump or move depends on uninitialised value(s) Occurs on first occurence of slave timeout. Reported by Henrik Munktell. +- Fix #457200 - FreeBSD support + Patch provided by Norbert Koch. libmodbus 2.0.3 (2009-03-22) ============================ diff --git a/src/modbus.c b/src/modbus.c index 669d4b1..66236ef 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -31,7 +31,12 @@ #include #include #include +#ifdef HAVE_INTTYPES_H +#include +#endif +#ifdef HAVE_STDINT_H #include +#endif #include #include #include @@ -43,11 +48,18 @@ #include #include #include +#if defined(__FreeBSD__ ) && __FreeBSD__ < 5 +#include +#endif #include #include #include #include +#if !defined(UINT16_MAX) +#define UINT16_MAX 0xFFFF +#endif + #include "config.h" #include "modbus.h" @@ -1714,7 +1726,7 @@ static int modbus_connect_tcp(modbus_param_t *mb_param) ret = setsockopt(mb_param->fd, IPPROTO_TCP, TCP_NODELAY, (const void *)&option, sizeof(int)); if (ret < 0) { - perror("setsockopt"); + perror("setsockopt TCP_NODELAY"); close(mb_param->fd); return ret; } @@ -1726,10 +1738,10 @@ static int modbus_connect_tcp(modbus_param_t *mb_param) **/ /* Set the IP low delay option */ option = IPTOS_LOWDELAY; - ret = setsockopt(mb_param->fd, IPPROTO_TCP, IP_TOS, + ret = setsockopt(mb_param->fd, IPPROTO_IP, IP_TOS, (const void *)&option, sizeof(int)); if (ret < 0) { - perror("setsockopt"); + perror("setsockopt IP_TOS"); close(mb_param->fd); return ret; } diff --git a/src/modbus.h b/src/modbus.h index b18f513..2c17b21 100644 --- a/src/modbus.h +++ b/src/modbus.h @@ -18,8 +18,19 @@ #ifndef _MODBUS_H_ #define _MODBUS_H_ +#ifdef HAVE_INTTYPES_H +#include +#endif +#ifdef HAVE_STDINT_H #include +#endif #include +#if defined(__FreeBSD__ ) && __FreeBSD__ < 5 +#include +#endif +#include +#include +#include #include #ifdef __cplusplus diff --git a/tests/unit-test-master.c b/tests/unit-test-master.c index b00dd31..309dab9 100644 --- a/tests/unit-test-master.c +++ b/tests/unit-test-master.c @@ -30,6 +30,7 @@ int main(void) { uint8_t *tab_rp_status; uint16_t *tab_rp_registers; + uint16_t *tab_rp_registers_bad; modbus_param_t mb_param; int i; uint8_t value; @@ -475,7 +476,7 @@ int main(void) printf("\nTEST BAD RESPONSE ERROR:\n"); /* Allocate only the required space */ - uint16_t *tab_rp_registers_bad = (uint16_t *) malloc( + tab_rp_registers_bad = (uint16_t *) malloc( UT_HOLDING_REGISTERS_NB_POINTS_SPECIAL * sizeof(uint16_t)); ret = read_holding_registers(&mb_param, UT_HOLDING_REGISTERS_ADDRESS, diff --git a/tests/unit-test.h b/tests/unit-test.h index 4984f95..0c08dbd 100644 --- a/tests/unit-test.h +++ b/tests/unit-test.h @@ -18,13 +18,18 @@ #ifndef _UNIT_TEST_H_ #define _UNIT_TEST_H_ +#ifdef HAVE_INTTYPES_H +#include +#endif +#ifdef HAVE_STDINT_H #include +#endif #define SLAVE 0x11 const uint16_t UT_COIL_STATUS_ADDRESS = 0x13; const uint16_t UT_COIL_STATUS_NB_POINTS = 0x25; -const uint8_t UT_COIL_STATUS_TAB[] = { 0xCD, 0x6B, 0xB2, 0x0E, 0x1B }; +const uint8_t UT_COIL_STATUS_TAB[] = { 0xCD, 0x6B, 0xB2, 0x0E, 0x1B }; const uint16_t UT_INPUT_STATUS_ADDRESS = 0xC4; const uint16_t UT_INPUT_STATUS_NB_POINTS = 0x16;