Hello all,
Happy new year! I am a masters student working on a project involving Modbus communication. I am using a Raspberry Pi (with TCP/IP) for the project along with libmodbus5 Debian release (version 3.0.6 -2). After I had encountered some problems I thought the better way is to ask someone who knows the library well. So here are my problems:
1. I guess the library uses a blocking connection call. (Can you please confirm the same?). I was not able to connect/reconnect to a device for some time (<4min) using the modbus_connect() function call. Is there a workaround rather than waiting for "connection timed out"? I had also set the time out using modbus_set_response_timeout() function, but it did not work. I guess it works only if there exists a connection and the server replies.
2. I had used the same modbus_connect() function call for a reconnection, in case any communication fails. Should I necessarily use modbus_close() and open the connection again ? I had implemented the same and shielded the modbus_close() with a sleep(5) to make sure that closing the socket does not affect the other devices connected to the same port 502. This had avoided the “Bad file descriptor” error if any communication was made immediately after closing the port.
3. I had seen the documentation and one of them stated that non-blocking modes were already implemented (from version 3.1). So can I download, compile and use the same on Pi ? Does it work directly after compiling the C files to get .o files and linking them? What might be the possible disadvantages? (I suppose one might be that it was not ARM specific.). I need your advice in this direction as I am new to Linux/ Debian.
regards
Hello all,
Happy new year! I am a masters student working on a project involving Modbus communication. I am using a Raspberry Pi (with TCP/IP) for the project along with libmodbus5 Debian release (version 3.0.6 -2). After I had encountered some problems I thought the better way is to ask someone who knows the library well. So here are my problems:
1. I guess the library uses a blocking connection call. (Can you please confirm the same?). I was not able to connect/reconnect to a device for some time (<4min) using the modbus_connect() function call. Is there a workaround rather than waiting for "connection timed out"? I had also set the time out using modbus_set_response_timeout() function, but it did not work. I guess it works only if there exists a connection and the server replies.
2. I had used the same modbus_connect() function call for a reconnection, in case any communication fails. Should I necessarily use modbus_close() and open the connection again ?
I had implemented the same and shielded the modbus_close() with a sleep(5) to make sure that closing the socket does not affect the other devices connected to the same port 502. This had avoided the “Bad file descriptor” error if any communication was made immediately after closing the port.
3. I had seen the documentation and one of them stated that non-blocking modes were already implemented (from version 3.1). So can I download, compile and use the same on Pi ?
Does it work directly after compiling the C files to get .o files and linking them?
What might be the possible disadvantages? (I suppose one might be that it was not ARM specific.).