modbus.c:164: error: `MSG_DONTWAIT' undeclared

Bug #375926 reported by Yishin Li
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libmodbus
Fix Released
Low
Stéphane Raimbault

Bug Description

The trunk branch can not be build on Cygwin.

Error message:
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT modbus.lo -MD -MP -MF .deps/modbus.Tpo -c modbus.c -DDLL_EXPORT -DPIC -o .libs/modbus.o
modbus.c: In function `modbus_flush':
modbus.c:164: error: `MSG_DONTWAIT' undeclared (first use in this function)

Reason:
There's no MSG_DONTWAIT macro defined in /usr/include/cygwin/socket.h

Related branches

Revision history for this message
Stéphane Raimbault (sra) wrote :

Try to replace MSG_DONTWAIT by 0 and add a printf just before
then run the unit test named unit-test-master (you need to run unit-test-slave before).

Try to observe the behaviour when a flush occurs to see if the call to recv() is blocking with your flag.

Revision history for this message
Yishin Li (yishin-li) wrote :

The compile process passed after replacing MSG_DONTWAIT by 0.
However, I hit "Bug #333455" while launching unit-test-master.
After workaround it, I got the following error message:

$ ./unit-test-master.exe :
TEST BAD RESPONSE ERROR:
ERROR Quantity not corresponding to the query (3 != 2) (10)
modbus_flush(): before recv()
modbus_flush(): after recv(), ret(2)
modbus_flush(): before recv()

$ ./unit-test-slave.exe :
Waiting for a message...
<00><14><00><00><00><06><FF><03><00><6B><00><02>
[00][14][00][00][00][09][FF][03][06][02][2B][00][00][00][64]
Waiting for a message...
Error in modbus_listen (-19)
Waiting for a message...
Error in modbus_listen (-19)
Waiting for a message...
Error in modbus_listen (-19)

Revision history for this message
Yishin Li (yishin-li) wrote :

> Try to observe the behaviour when a flush occurs to see if the call to recv() is blocking with your flag.

You are right; the unit-test-master got blocked by the recv() as there's no more messages coming from the TCP/IP queue. I'm thinking of implementing modbus_flush() with pselect() or ppoll(). Is it reasonable?

Sorry about that I didn't pay too much attention on this issue. Basically because I'm new to modbus, and don't have strong idea about it.

BTW, I am currently evaluating a suitable communication protocol for real-time control through USB interface. I will post my question on the Answer forum later.

-Yishin

Revision history for this message
Stéphane Raimbault (sra) wrote :

Could you try the following patch?

Revision history for this message
Yishin Li (yishin-li) wrote :

Yes, it works!

Attached is my patch, which remove printf() for select() and check if there's error returned by select().

Yishin Li (yishin-li)
Changed in libmodbus:
status: New → In Progress
Yishin Li (yishin-li)
Changed in libmodbus:
status: In Progress → Fix Committed
Revision history for this message
Stéphane Raimbault (sra) wrote :

The fix wasn't committed yet

Changed in libmodbus:
assignee: nobody → Stéphane Raimbault (sra)
importance: Undecided → Low
milestone: none → 2.2.0
Revision history for this message
Yishin Li (yishin-li) wrote :

I'm new to bazaar, and kind of get confused by it @@
I thought I was commit my modification.
Now, I realized that was just committing to my local repository.

The "bzr merge" gave me a lot of conflicts and messages that I don't quiet understand. I'm a CVS/SVN user, and am currently studying the Bazaar User Guide.

Changed in libmodbus:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.