Skip to content
This repository was archived by the owner on Jul 24, 2022. It is now read-only.
This repository was archived by the owner on Jul 24, 2022. It is now read-only.

Cannot WriteSingleRegister ModbusSerialRtuSlave #177

Description

@MarkDaviesSensei

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions