Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time out problem #70

Open
einarbjorkman opened this issue Jul 16, 2022 · 0 comments
Open

Time out problem #70

einarbjorkman opened this issue Jul 16, 2022 · 0 comments

Comments

@einarbjorkman
Copy link

Hello,
I am having the following problem:
I am using a function (from another library) called CN0391_set_data( ).
This function is quite time consuming and causes the slave.poll( ) function to time out.
(Note: I get the same problem when replacing CN0391_set_data( ) with for example delay(2000) or delay(5000)).
I have tried solving this with the following code (my actual sketch has more, but I left it out as I know this is not the problem):

#include <ModbusRtu.h>

#define TXEN 3

uint16_t roastData[16] = {
  241, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 
};

Modbus slave(1,Serial,TXEN); 

uint16_t timeOutVal = 10000;

/*********************************************************************************/

void setup() {

Serial.begin(19200);

slave.start();
delay(10);
slave.setTimeOut( timeOutVal );
}

However the time-out time for slave.poll( ) does not appear to have changed.
I say this because when reading registers with a Modbus troubleshooting tool (ModbusTool (V1.1.1.0)) I get the error message
"Block with function 3 is timed out" (I am doing read holding registers) after around 1 second.
If the time-out for slave.poll( ) was actually 10000 ms (and the error lay elsewhere) then you would expect this time to pass and then for the error message to occur.
So my question is this:
How can I modify the time-out time for slave.poll?
Can this be done with functions available through including the library or do I have to modify the .h file in some way?

/ Einar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant