static int RunWrite16(Write16Options opts) { using (var client = new ModbusRtuClient()) { client.PortName = opts.PortName; client.BaudRate = opts.BaudRate; client.DataBits = opts.DataBits; client.Parity = opts.Parity; if (!OpenPort(client)) { return(1); } client.WriteMultipleHoldingRegisters(opts.UnitAddress, opts.RegisterAddress, opts.RegisterValues.ToArray()); return(0); } }