rossmann-engineering / EasyModbusTCP.NET

Modbus TCP, Modbus UDP and Modbus RTU client/server library for .NET implementations
922 stars 396 forks source link

Serial Port Parity #73

Open wecoxSand opened 2 years ago

wecoxSand commented 2 years ago

Using an empty constructor to generate a ModbusClient, then setting its properties. Setting ModbusClient.Parity = Parity.None; before calling .Connect() results in the internal serialport still creating with Parity.Even

Padanian commented 2 years ago

It all boils down to this deprecable getter/setter

        public Parity Parity
        {
            get
            {
                if (serialport != null)
                    return parity;
                else
                    return Parity.Even;
            }
            set
            {
                if (serialport != null)
                    parity = value;
            }
        }

Definining a property with the same name of an enum is a terrible idea. Also Parity.Even is returned when serialport is null.