Skip to content

Time out problem #70

@einarbjorkman

Description

@einarbjorkman

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions