On 05/07/2017 07:09 AM, suavesteve wrote:
> I've come across this earlier and had created a local patch,
>
> Tested with both v3.0.6 and v3.1.4 (Latest Stable release)

Thanks Philip/suavesteve for posting that!

It's strange to me that the libmodbus folks went from using a struct 
timeval for their timeout to passing the fields individually, but sure 
enough they did.

According to http://libmodbus.org, 3.0 is stable and 3.1 is still listed 
as unstable, even though it's been around for years and has had several 
stable-looking "releases".

Some feedback on your patch:

You pass timeout.tv_sec for both the seconds and the microseconds, I 
think you meant to pass timeout.tv_usec for the third argument.  Details 
on that here: 
http://libmodbus.org/docs/v3.1.4/modbus_set_response_timeout.html

Instead of taking the pointer of timeout and dereferencing it 
("(uint32_t) (&timeout)->tv_sec"), it's simpler and clearer to just use 
the field directly ("(uint32_t)timeout.tv_sec").

There's a bug in the #if you use for version detection, think about (for 
example) a hypothetical future version 4.0.  Use LIBMODBUS_VERSION_HEX 
instead of LIBMODBUS_VERSION_MAJOR and LIBMODBUS_VERSION_MINOR.  Instead 
of this:

+    #if LIBMODBUS_VERSION_MAJOR >= 3 && LIBMODBUS_VERSION_MINOR >= 1

Use this (untested):

+    #if LIBMODBUS_VERSION_HEX >= 0x03010000


If you make those changes, and sign off on your commit (see 
http://linuxcnc.org/docs/devel/html/code/contributing-to-linuxcnc.html#_signed_off_by_policy),
 
then I'll gladly apply your patch in LinuxCNC 2.7.


-- 
Sebastian Kuzminsky

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to