I am trying to read from a modbus comport inside a docker IoT Edge module. I have supplied the relevant createOptions:
{ "HostConfig": { "Isolation": "Process", "Devices": [ { "PathOnHost": "class/86E0D1E0-8089-11D0-9CE4-08003E301F73", "PathInContainer": "", "CgroupPermissions": "" } ], "Binds": [ "C:/Streamwise:C:/Streamwise" ] } }
This works flawlessly on some ipcs but fails on others with a
System.IO.FileNotFoundException: Could not find file 'COM4'. File name: 'COM4'
when I try to open the serail port
This is the same error I receive if I dont specify any createOptions. So it appears that those options are not being applied. Any idea why?
Code snippet below
public static void Connect(string portName)
{
Console.WriteLine(portName);
// Configure serial port
SerialPort port = new SerialPort(portName, 9600, Parity.None, 8, StopBits.One);
port.Open();
master = new ModbusFactory().CreateRtuMaster(new SerialPortAdapter(port));
master.Transport.ReadTimeout = 200;
master.Transport.WriteTimeout = 200;
}
Error occurs on port.open()
Additional context: for some reason on ipcs where I have to specify DNS server inside daemon.json for iotedge-moby, this problem occurs. Not sure if they are related or pure conincidence.