Skip to content

Conversation

mhei
Copy link
Contributor

@mhei mhei commented Sep 28, 2013

I've a device which implements custom modbus functions. Receiving the response for this functions is only possible when libmodbus knows about the response length. As various device could implement the same function codes its up to the program using the modbus library to calculate/provide the response length correctly. So this two patches are a RFC to deal with such situations.

@stephane
Copy link
Owner

stephane commented Oct 6, 2013

Hi Michael,

I intend to add a callback support to libmodbus for years! I'll try to give feedback on your RFC in following weeks

@daschuer
Copy link
Contributor

daschuer commented Nov 5, 2013

Hi Michael,

Thank you for your branch.
What was the reason to introduce a common callback function type using ...
For me this looks like a source for runtime errors if the user messes with the function types.

Kind regards,

Daniel

@mhei
Copy link
Contributor Author

mhei commented Nov 5, 2013

Hi Daniel,

your are right, me too, I'm wondering whether this is the correct approach for a library. When I coded this PR, my main intension was to indicate the/my need for my particular requirement and to get a discussion started - as we do here :-)
As indicated, take this as an RFC.
What do you think or which approach do you prefer? For each callback a single function type?

Best regards,
Michael

@daschuer
Copy link
Contributor

daschuer commented Nov 5, 2013

Hi Michael,

Yes, I would prefer a fixed function type for each callback. I have also
seen one common callback with an additional parameter telling why it is
called.

I am currently working at the QModBus tool. There is a need for two
additional callbacks to implement a bus Monitor.

Kind regards,

Daniel

2013/11/5 Michael Heimpold notifications@github.com

Hi Daniel,

your are right, me too, I'm wondering whether this is the correct approach
for a library. When I coded this PR, my main intension was to indicate
the/my need for my particular requirement and to get a discussion started -
as we do here :-)
As indicated, take this as an RFC.
What do you think or which approach do you prefer? For each callback a
single function type?

Best regards,
Michael


Reply to this email directly or view it on GitHubhttps://github.com//pull/140#issuecomment-27769379
.

mhei added 2 commits February 13, 2015 20:41
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
When a Modbus device supports vendor specific function codes, then
the current length calculation is not sufficient. Allow the calling
programm to register callback functions which can handle such cases.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
@karlp
Copy link
Contributor

karlp commented Sep 4, 2019

This would ~solve the core issues in #231 and #344

The following issues could then become "trivially" implemented in user code, instead of requiring library mods to function at all.
#407
#330
#449
#431
#474

@dangowrt
Copy link

Beautiful. Would allow me to use libmodbus in https://github.com/dangowrt/tracertools/ ... Just that EP also uses a function code reserved for error handling (supposedly they miscalculated decimal 100 as 0xA0...)

@ekigwana
Copy link

ekigwana commented Dec 2, 2021

How unfortunate that I now have to roll my own because this is exactly what I needed.Considering this idea with a contributed patch has not made it since September 2013, there is no point to trying to convince anyone here or even contributing patches!

Another example of hardware where this library does not work SeaLevel SeaI/O 462

The irritating part is that I almost got all the way there using the other inefficient methods. That is until I got ERROR Illegal data address at address 88 when using modbus_read_input_bits. I'll never get my 2 days back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants