Update reading and writing modbus protocol by a waiting time
This commit is contained in:
parent
037b411d6b
commit
a094c4f080
|
|
@ -29,7 +29,7 @@ public class SerialPortChannel : ConnectionChannel<SerialPort>
|
|||
{
|
||||
var serialPort = new SerialPort(portName, baudRate, parity, dataBits, sb)
|
||||
{
|
||||
ReadTimeout = 1000, // milliseconds
|
||||
ReadTimeout = 1000, // milliseconds
|
||||
WriteTimeout = 1000 // milliseconds
|
||||
};
|
||||
serialPort.Open();
|
||||
|
|
|
|||
|
|
@ -37,11 +37,11 @@ public class ModbusDevice<[DynamicallyAccessedMembers(All)] R> where R : notnull
|
|||
|
||||
public R Read(R record)
|
||||
{
|
||||
// Console.WriteLine($"Reading { _Batches.Count } Modbus batches.");
|
||||
//Console.WriteLine($"Reading { _Batches.Count } Modbus batches.");
|
||||
foreach (var batch in _Batches)
|
||||
{
|
||||
batch.Read(record);
|
||||
Thread.Sleep(50); // this added mainly for Growatt reading
|
||||
Thread.Sleep(30); // this added mainly for Growatt reading
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
|
@ -49,6 +49,9 @@ public class ModbusDevice<[DynamicallyAccessedMembers(All)] R> where R : notnull
|
|||
public void Write(R record)
|
||||
{
|
||||
foreach (var batch in _Batches)
|
||||
{
|
||||
batch.Write(record);
|
||||
Thread.Sleep(50); // this added mainly for Growatt reading
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue