hacker-cb / modbus-dart

BSD 3-Clause "New" or "Revised" License
37 stars 22 forks source link

How to set Response timeout? #28

Open nancyyihao opened 1 year ago

nancyyihao commented 1 year ago

I want to set a timeout if modbus slave not response in a given time(like 2000ms), how can I do it ?

ElegantCrab commented 1 year ago

With a simple solution you could do this

var coils = await _client.readCoils(1,1).timeout(Duration(miliseconds: 2000), onTimeout: () {
   //Do something
});