I'm using com0com to simulate the com ports
I have the following code which creates a slave
`
public static SerialPort sp = null;
...
private static void Main(string[] args)
{
sp = new SerialPort("COM5", 9600, Parity.None, 8, StopBits.One);
sp.Open();
new Thread((p) => StartModbusSerialRtuSlave()).Start();
byte slaveId = 1;
ushort register = 1;
ushort item = 5;
IModbusSerialMaster master1 = ModbusSerialMaster.CreateRtu(sp);
master1.WriteSingleRegister(slaveId, register, item);
}
public static void StartModbusSerialRtuSlave()
{
byte unitId = 1;
slave = ModbusSerialSlave.CreateRtu(unitId, sp);
slave.DataStore = DataStoreFactory.CreateDefaultDataStore();
slave.Listen();
}
`
The slave bit works fine, and I use modbustool.com modbuspoll app to connect on com6 and read its creates a successful connection
However, as soon as I try and WriteSingleRegister, it fails with error:
The I/O operation has been aborted because of either a thread exit or an application request.
Any is this something to do with how i've implemented this or a bug ?
I'm using com0com to simulate the com ports
I have the following code which creates a slave
`
public static SerialPort sp = null;
...
private static void Main(string[] args)
{
sp = new SerialPort("COM5", 9600, Parity.None, 8, StopBits.One);
sp.Open();
new Thread((p) => StartModbusSerialRtuSlave()).Start();
byte slaveId = 1;
ushort register = 1;
ushort item = 5;
IModbusSerialMaster master1 = ModbusSerialMaster.CreateRtu(sp);
master1.WriteSingleRegister(slaveId, register, item);
}
public static void StartModbusSerialRtuSlave()
{
byte unitId = 1;
slave = ModbusSerialSlave.CreateRtu(unitId, sp);
slave.DataStore = DataStoreFactory.CreateDefaultDataStore();
slave.Listen();
}
`
The slave bit works fine, and I use modbustool.com modbuspoll app to connect on com6 and read its creates a successful connection
However, as soon as I try and WriteSingleRegister, it fails with error:
The I/O operation has been aborted because of either a thread exit or an application request.
Any is this something to do with how i've implemented this or a bug ?