How to make non-blocking calls in libmodbus?

Asked by Abid

Hi

I am using Libmodbus to link an embedded processor running an RTOS to a PLC.

I need to use the read_register call() and preset_register() function calls to read and set contents of the holding register area in the PLC.

How can I make non blocking function calls so that the modbus packet is sent to the PLC immediately and the function returns to the caller rather then wait for a response packet from the PLC which will generally occur at the end of a scan period.

I would like to send a read_register() packet followed by a preset_registers() packet, continue processing for a period and then readback the modbus response packets.

Any help would be appreciated.

Thanks in advance

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
picoworm (picoworm) said :
#1

I was needed almost the same thing. So, last few days I have changing whole library.
I split it to 4 libraries.
3 of them can be used separately from each other:
   comm_serial.c - Library for working with serial ports in linux
   comm_tcp.c - Library for working with TCP/IP protocol
   modbus.c - Library, that only generates outgoing and analyses incoming messages (have to be OS-independent)

Last file is modbus_comm.c. It used to abstract user from communication libraries, as it were done in previous version.

For now the library has some bugs, so I do not release it while debugging.

I will send You current version.

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

picoworm, the Modbus library is under LGPL so you need to publish your code to everyone. Could you provide a link, please?

Feel free to propose some patches to the current version to add async behaviour.

Revision history for this message
Todd Denniston (todd-denniston) said :
#3

Stéphane Raimbault wrote, On 07/30/2009 08:50 PM:
> Question #75753 on libmodbus changed:
> https://answers.launchpad.net/libmodbus/+question/75753
>
> Stéphane Raimbault proposed the following answer:
> picoworm, the Modbus library is under LGPL so you need to publish your
> code to everyone. Could you provide a link, please?
>

IANAL, but my understanding of the LGPL is that picoworm would need to publish his/her code ONLY to
those s/he gave a binary of it to, and as long as what picoworm sent to Abid was the source code,
then picoworm has done an appropriate thing.

if picoworm only sent a binary, then picoworm probably needs to remember the extension of an offer
to send the source code in accordance with the LGPL to Abid.

Just trying to say, your answer _felt_ more like a an over demand than _I_ felt strictly necessary.

Of course nothing, except trying to let picoworm get his/her code in better shape first, would then
legally stop Abid from releasing when Abid got. :)

> Feel free to propose some patches to the current version to add async
> behaviour.

My reading was that picoworm would probably publish wider when picoworm's code was a little more
stable. But I suspect if you were given access, the stabilization process might be sped along
because of your interest. :)

--
Todd Denniston
Crane Division, Naval Surface Warfare Center (NSWC Crane)
Harnessing the Power of Technology for the Warfighter

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

Thank you, Todd.
Of course, the licence is tied to the distribution of the software.

Revision history for this message
Niels Ole Salscheider (niels-ole) said :
#5

I am really interested in these changes to libmodbus. Are there any news?

Revision history for this message
picoworm (picoworm) said :
#6

Look my code at - http://sites.google.com/site/picoworminfo/files

I had some problems when pushing new bzr branch, so it will be on my web-site for some-time

Some description is in header files. Tested with tcp (single and multiclient) and rtu

Used with Xenomai reatime subsystem.

Can you help with this problem?

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

To post a message you must log in.