using (TcpClient client = new TcpClient("127.0.0.1", 1502))
            {
                var factory = new ModbusFactory();
                IModbusMaster master = factory.CreateMaster(client);

                // read five input values
                ushort startAddress = 100;
                ushort numInputs = 5;
                //bool[] inputs = master.ReadInputs(1, startAddress, numInputs);

                ushort[] registers = master.ReadHoldingRegisters(1, 4003, 1);

               
               
            }

            for (int i = 0; i < this.dataGridViewReadConfig.Rows.Count-1; i++)
            {
                string unit = textBoxUnit.Text.ToString();
                string startAddress = this.dataGridViewReadConfig.Rows[i].Cells[1].Value.ToString();
              
                string number = this.dataGridViewReadConfig.Rows[i].Cells[2].Value.ToString();
                var shortData = client.ReadHoldingRegisters<ushort>(1, 4003,  1);

                foreach (var item in shortData)
                {
                    this.dataGridViewReadConfig.Rows[i].Cells[4].Value = item+",";
                }
               
            }
		使用组件库
		FluentModbus
		NModbus

相关文章:

  • 2021-10-17
  • 2021-05-25
  • 2022-12-23
  • 2022-02-22
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案