我有一个Fatek Fbs PLC,离散输入连接到X0(001001)寄存器。我想通过C#读取这些输入值。我尝试过EasymodbusTCP库,但无法正常工作。
ModbusClient modbusClient = new ModbusClient("190.201.100.100", 502); modbusClient.Connect();
bool[] readCoils = modbusClient.ReadCoils(0,10);
int[] readHoldingRegisters = modbusClient.ReadHoldingRegisters(0,10);
string val=modbusClient.ReadDiscreteInputs(0,1)[0].ToString()); //this line throws exception