building a function "modbus udp"

Asked by Steven Hsu

I would like to add a UDP transfer function instead of the default TCP, can I just follow the code format inside modbus.c and modbus.h or need to modify many other files? thanks.

Question information

Language:
English Edit question
Status:
Answered
For:
libmodbus Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Stéphane Raimbault (sra) said :
#1

2010/6/5 Steven Hsu <email address hidden>:
> New question #113582 on libmodbus:
> https://answers.launchpad.net/libmodbus/+question/113582
>
> I would like to add a UDP transfer function instead of the default TCP, can I just follow the code format inside modbus.c and modbus.h or need to modify many other files? thanks.

Take care to use the source code from github and yes, for now, you
only need to edit modbus.[ch] to do that.

Revision history for this message
Steven Hsu (sintsu1101) said :
#2

Thanks for your quick response.

I spent whole night try to modify the source code and the confilct between tcp and udp, also the bandwidth-master.c, bandwidth-slave-many-up.c under tests folder. But ...It seems like the modbus client cannot receive the packet from other modbus server (I used tcpdump to monitor the packet and check the firewall or route problem) but success in localhost but the slave shows "the Illegal data address XXX in read_holding_registers".

I copy the function structure of tcp for the udp function, comment the code that udp wont need (like accept and listen) but infact I'm not very familar with it ...
I think maybe libmodbus can impliment such function inside the origin program.

http://163.22.32.100/~sintsu/libmodbus-udp.tar

Revision history for this message
Stéphane Raimbault (sra) said :
#3

Could you provide a patch for review or a git branch please?

Revision history for this message
Stéphane Raimbault (sra) said :
#4

2010/6/6 Steven Hsu <email address hidden>:
> Question #113582 on libmodbus changed:
> https://answers.launchpad.net/libmodbus/+question/113582
>
>    Status: Answered => Open
>
> Steven Hsu is still having a problem:
> Thanks for your quick response.
>
> I spent whole night try to modify the source code and the confilct
> between tcp and udp, also the bandwidth-master.c, bandwidth-slave-many-
> up.c under tests folder. But ...It seems like the modbus client cannot
> receive the packet from other modbus server (I used tcpdump to monitor
> the packet and check the firewall or route problem) but success in
> localhost but the slave shows "the Illegal data address XXX in
> read_holding_registers".
>
> I copy the function structure of tcp for the udp function, comment the code that udp wont need (like accept and listen) but infact I'm not very familar with it ...
> I think maybe libmodbus can impliment such function inside the origin program.
>
> http://163.22.32.100/~sintsu/libmodbus-udp.tar
>

I don't have time to review your code but I've made major changes in
the code this summer to ease the implementation of multiple backends
(only RTU and TCP for now). Could you rebase your UDP code on master
branch and create an UDP backend, please?

The best way to do this, it to create a fork of my master branch on
github (a branch called udp for example) and to apply small and atomic
commits to your branch, so it will be easier for me to review your
code and merge your branch.

Stephane

Revision history for this message
Stéphane Raimbault (sra) said :
#5

LinkedIn
------------

I'd like to add you to my professional network on LinkedIn.

- Stéphane Raimbault

Stéphane Raimbault
Open Source Project Leader and Software developer at Makina Corpus
Nantes Area, France

Confirm that you know Stéphane Raimbault
https://www.linkedin.com/e/-x1fm20-gl214683-3h/isd/2469859645/y4fcKyJt/

--
(c) 2011, LinkedIn Corporation

Can you help with this problem?

Provide an answer of your own, or ask Steven Hsu for more information if necessary.

To post a message you must log in.