diff --git a/doc/index.md b/doc/index.md index ae23603..e8ec5ad 100644 --- a/doc/index.md +++ b/doc/index.md @@ -408,12 +408,12 @@ It might happen that a server should not support all Modbus functions or only a var server = new ModbusTcpServer() { - RequestValidator = (unitIdentifier, functionCode, address, quantityOfRegisters) => + RequestValidator = (args) => { - if (functionCode == ModbusFunctionCode.WriteSingleRegister) + if (args.FunctionCode == ModbusFunctionCode.WriteSingleRegister) return ModbusExceptionCode.IllegalFunction; - else if (address < 5 || address > 15) + else if (args.Address < 5 || args.Address > 15) return ModbusExceptionCode.IllegalDataAddress; else diff --git a/doc/samples/modbus_validator.md b/doc/samples/modbus_validator.md index 826f483..cb79691 100644 --- a/doc/samples/modbus_validator.md +++ b/doc/samples/modbus_validator.md @@ -8,21 +8,17 @@ var server = new ModbusTcpServer() RequestValidator = this.ModbusValidator; }; -private ModbusExceptionCode ModbusValidator( - byte unitIdentifier, - ModbusFunctionCode functionCode, - ushort address, - ushort quantityOfRegisters) +private ModbusExceptionCode ModbusValidator(RequestValidatorArgs args) { // check if address is within valid holding register limits - var holdingLimits = (address >= 50 && address < 90) || - address >= 2000 && address < 2100; + var holdingLimits = (args.Address >= 50 && args.Address < 90) || + args.Address >= 2000 && args.Address < 2100; // check if address is within valid input register limits - var inputLimits = address >= 1000 && address < 2000; + var inputLimits = args.Address >= 1000 && args.Address < 2000; // go through all cases and return proper response - return (functionCode, holdingLimits, inputLimits) switch + return (args.FunctionCode, holdingLimits, inputLimits) switch { // holding registers (ModbusFunctionCode.ReadHoldingRegisters, true, _) => ModbusExceptionCode.OK,