Open fenilGhoghari opened 1 year ago
Hello @Fenil, @Stephane and all interested
That's the same behavior I reported few years ago. Also Qt application, also copied the recommended opening and closing sequences from libmodbus docs.
Maybe we can focus on properly flushing all the data before closing the port. My micro-controller devices using code modified from libmodbus are going crazy when incomplete data frame is stuck in buffers.
The only one different correlation I can see is that in both cases, libmodbus code is called from c++ project.
Have a nice day
Jakub Ladman
@ladmanj could you confirm the issue is still present (docs and code). I don't understand why calling modbus_close
from C++ code would be an issue. Do you a snippet C++ code to compile to observe the issue?
BTW don't free(m_modbus->backend_data)
after a call to modbus_free
.
https://github.com/stephane/libmodbus/blob/master/src/modbus-rtu.c#L1169 https://github.com/stephane/libmodbus/blob/master/src/modbus-tcp.c#L816
Hello @stephane ,
I have used your library in QT framework and i am trying to make one QT application but when I first time launch my application at a time i am able to make connection but when i dis-connect with current client and using same IP and PORT at a time my server is not closed and try to connect with my client but i am not able to connect with my second client can you help me to close the Binding hear.
I am sure here port is not closed completely and this make issue to new connection. I didn't modify your disconnect function and i am using as it is you have written.
Environment I used: System : Windows 10 and Debian QT version: 5.15.0
How I tested? -> First launch application using QT Creature -> Launch Server -> Connect with client ( Success) -> Client Disconnect ( Success) -> Relaunch Client ( Same IP and Port) ( Fail)
Expected Outcome: -> Server Able to connect with Client
I hope you will help me out to solve this issue I will be grateful to you if you help me here!!!
My Code for Server
Disconnect Function
Thanks & Regards, Fenil