Skip to content

Conversation

@frodete
Copy link

@frodete frodete commented Mar 31, 2016

The modbus_reply_callback() function is modelled closely on modbus_reply(),
but should be used when more complex actions are required for handling
Modbus functions that what is possible with the current mapping scheme.

The modbus_reply_callback() function is modelled iclosely on modbus_reply(),
but should be used when more complex actions are required for handling
Modbus functions that what is possible with the current mapping scheme.
@stephane
Copy link
Owner

Thank you for your patch and the very good documentation.
The patch duplicates too many lines of code.

I think we can achieve the same behaviour with #323.

It would be nice if you could participate to this new feature (tests, docs, whatever), I'm intend to talk about that on the mailing list... stay tuned.

@frodete
Copy link
Author

frodete commented May 18, 2016

It has been a while since I coded this together for a project and only recently managed to push it. I agree that there are some duplication in the code. However, when I started to make this I did try to look at some way to reduce the duplication. There were a few reasons why I ended up with what I did:

  1. I didn't want to break existing code base. Not a real reason - unless you'r on a deadline. :)
  2. I didn't want to pollute the code with additional branches which could adversely affect the branch predictor (i.e. less code, but worse performance).
  3. My initial attempts produced code which was much worse from a maintenance perspective.
  4. All in all, the total number of identical code lines between the two functions are relatively low - there are probably more duplications internally in each functions, like the error handling.

I am no longer involved in the project which spawned this patch, but I will try to contribute in any way I can.

yegorich and others added 27 commits May 29, 2016 14:55
msinttypes moved to GitHub, so change URL accordingly.
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Stéphane Raimbault <stephane.raimbault@gmail.com>
Thanks to Rüdiger Ranft for the idea.
@frodete
Copy link
Author

frodete commented May 29, 2016

I tried pushing four changes to this fork to address your concern, but it looks like I ended up with a merge mess. Does the changes make sense or should I start from scratch?

pboettch added a commit to pboettch/libmodbus that referenced this pull request Aug 7, 2017
Based on @frodete's proposal (stephane#319) a more minimalistic implementation
of a callback-based reply-function.

The old mapping-implementation is now based on this version. As a nice
side-effect some DRY code optimizations could have been done.
pboettch added a commit to pboettch/libmodbus that referenced this pull request Aug 7, 2017
Based on @frodete's proposal (stephane#319) a more minimalistic implementation
of a callback-based reply-function.

The old mapping-implementation is now based on this version. As a nice
side-effect some DRY code optimizations could have been done.
pboettch added a commit to pboettch/libmodbus that referenced this pull request Aug 8, 2017
Based on @frodete's proposal (stephane#319) a more minimalistic implementation
of a callback-based reply-function.

The old mapping-implementation is now based on this version. As a nice
side-effect some DRY code optimizations could have been done.
pboettch added a commit to pboettch/libmodbus that referenced this pull request Aug 11, 2017
Based on @frodete's proposal (stephane#319) a more minimalistic implementation
of a callback-based reply-function.

The old mapping-implementation is now based on this version. As a nice
side-effect some DRY code optimizations could have been done.
pboettch added a commit to pboettch/libmodbus that referenced this pull request Aug 14, 2017
Based on @frodete's proposal (stephane#319) this implementation adds a
a callback-based reply-functionality.

The old mapping-implementation is now based on this version. As a nice
side-effect some DRY code optimizations could have been done.

Also adds a MODBUS_SLAVE_ACCEPT_ALL "address", which can be used with
modbus_set_slave(). This makes the modbus_receive()-function accept
all requests, independently of the slave-address found in the
decoded-request. Useful for multi-slave-implementation using libmodbus.
pboettch added a commit to pboettch/libmodbus that referenced this pull request Aug 20, 2017
Based on @frodete's proposal (stephane#319) this implementation adds a
a callback-based reply-functionality.

The old mapping-implementation is now based on this version. As a nice
side-effect some DRY code optimizations could have been done.

Also adds a MODBUS_SLAVE_ACCEPT_ALL "address", which can be used with
modbus_set_slave(). This makes the modbus_receive()-function accept
all requests, independently of the slave-address found in the
decoded-request. Useful for multi-slave-implementation using libmodbus.
pboettch added a commit to pboettch/libmodbus that referenced this pull request Aug 20, 2017
Based on @frodete's proposal (stephane#319) this implementation adds a
a callback-based reply-functionality.

The old mapping-implementation is now based on this version. As a nice
side-effect some DRY code optimizations could have been done.

Also adds a MODBUS_SLAVE_ACCEPT_ALL "address", which can be used with
modbus_set_slave(). This makes the modbus_receive()-function accept
all requests, independently of the slave-address found in the
decoded-request. Useful for multi-slave-implementation using libmodbus.
pboettch added a commit to pboettch/libmodbus that referenced this pull request Oct 31, 2017
Based on @frodete's proposal (stephane#319) this implementation adds a
a callback-based reply-functionality.

The old mapping-implementation is now based on this version. As a nice
side-effect some DRY code optimizations could have been done.

Also adds a MODBUS_SLAVE_ACCEPT_ALL "address", which can be used with
modbus_set_slave(). This makes the modbus_receive()-function accept
all requests, independently of the slave-address found in the
decoded-request. Useful for multi-slave-implementation using libmodbus.
pboettch added a commit to pboettch/libmodbus that referenced this pull request Oct 31, 2017
Based on @frodete's proposal (stephane#319) this implementation adds a
a callback-based reply-functionality.

The old mapping-implementation is now based on this version. As a nice
side-effect some DRY code optimizations could have been done.

Also adds a MODBUS_SLAVE_ACCEPT_ALL "address", which can be used with
modbus_set_slave(). This makes the modbus_receive()-function accept
all requests, independently of the slave-address found in the
decoded-request. Useful for multi-slave-implementation using libmodbus.
pboettch added a commit to pboettch/libmodbus that referenced this pull request Dec 11, 2017
Based on @frodete's proposal (stephane#319) this implementation adds a
a callback-based reply-functionality.

The old mapping-implementation is now based on this version. As a nice
side-effect some DRY code optimizations could have been done.

Also adds a MODBUS_SLAVE_ACCEPT_ALL "address", which can be used with
modbus_set_slave(). This makes the modbus_receive()-function accept
all requests, independently of the slave-address found in the
decoded-request. Useful for multi-slave-implementation using libmodbus.
pboettch added a commit to pboettch/libmodbus that referenced this pull request Dec 11, 2017
Based on @frodete's proposal (stephane#319) this implementation adds a
a callback-based reply-functionality.

The old mapping-implementation is now based on this version. As a nice
side-effect some DRY code optimizations could have been done.

Also adds a MODBUS_SLAVE_ACCEPT_ALL "address", which can be used with
modbus_set_slave(). This makes the modbus_receive()-function accept
all requests, independently of the slave-address found in the
decoded-request. Useful for multi-slave-implementation using libmodbus.
pboettch added a commit to pboettch/libmodbus that referenced this pull request Sep 11, 2018
Based on @frodete's proposal (stephane#319) this implementation adds a
a callback-based reply-functionality.

The old mapping-implementation is now based on this version. As a nice
side-effect some DRY code optimizations could have been done.

Also adds a MODBUS_SLAVE_ACCEPT_ALL "address", which can be used with
modbus_set_slave(). This makes the modbus_receive()-function accept
all requests, independently of the slave-address found in the
decoded-request. Useful for multi-slave-implementation using libmodbus.
pboettch added a commit to pboettch/libmodbus that referenced this pull request Sep 12, 2018
Based on @frodete's proposal (stephane#319) this implementation adds a
a callback-based reply-functionality.

The old mapping-implementation is now based on this version. As a nice
side-effect some DRY code optimizations could have been done.

Also adds a MODBUS_SLAVE_ACCEPT_ALL "address", which can be used with
modbus_set_slave(). This makes the modbus_receive()-function accept
all requests, independently of the slave-address found in the
decoded-request. Useful for multi-slave-implementation using libmodbus.
ben-edna pushed a commit to ben-edna/libmodbus that referenced this pull request Jan 16, 2019
Based on @frodete's proposal (stephane#319) this implementation adds a
a callback-based reply-functionality.

The old mapping-implementation is now based on this version. As a nice
side-effect some DRY code optimizations could have been done.

Also adds a MODBUS_SLAVE_ACCEPT_ALL "address", which can be used with
modbus_set_slave(). This makes the modbus_receive()-function accept
all requests, independently of the slave-address found in the
decoded-request. Useful for multi-slave-implementation using libmodbus.
pboettch added a commit to pboettch/libmodbus that referenced this pull request Jan 28, 2020
Based on @frodete's proposal (stephane#319) this implementation adds a
a callback-based reply-functionality.

The old mapping-implementation is now based on this version. As a nice
side-effect some DRY code optimizations could have been done.

Also adds a MODBUS_SLAVE_ACCEPT_ALL "address", which can be used with
modbus_set_slave(). This makes the modbus_receive()-function accept
all requests, independently of the slave-address found in the
decoded-request. Useful for multi-slave-implementation using libmodbus.
pboettch added a commit to pboettch/libmodbus that referenced this pull request Feb 2, 2021
Based on @frodete's proposal (stephane#319) this implementation adds a
a callback-based reply-functionality.

The old mapping-implementation is now based on this version. As a nice
side-effect some DRY code optimizations could have been done.

Also adds a MODBUS_SLAVE_ACCEPT_ALL "address", which can be used with
modbus_set_slave(). This makes the modbus_receive()-function accept
all requests, independently of the slave-address found in the
decoded-request. Useful for multi-slave-implementation using libmodbus.
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.

5 participants