nrModbus1.SlaveRegisters.Register[1234] := 456; // access and change register 1234;
nrModbus1.SlaveCoils.Coil[88] := true; // access and change coil 88;
procedure TForm1.nrModbus1ModbusRequest(sender: TObject; Reply: TnrModbusPacket;
Registers: TnrModbusRegisterList; Coils: TnrModbusCoilList; isWrite: Boolean;
var error_code: TnrModbusError);
var
sCoil : string;
i:integer;
begin
sCoil := '';
for I := 0 to Coils.Count - 1 do
begin
sCoil := sCoil + 'Device: ' + IntToStr(Reply.Address) + ' Coil:' + IntToStr(Coils.GetCoilNumber(i)) + ' = ' + IntToHex(Coils.GetCoilValue(i).ToInteger(), 4) + #13#10;
// listbox1.items.add('in modbus request : '+sreg);
end;
mmoErrorLog.Lines.Add(sCoil);
end;