Exemplo n.º 1
0
        public async Task TestUShort()
        {
            var           factory = new ModbusFactory();
            IModbusMaster modbus  = factory.CreateMaster(_client);
            await _client.ConnectAsync(MODBUS_IP, MODBUS_PORT);

            ushort?data = await modbus.ReadUShortAsync(MODBUS_SLAVE, 0);

            Assert.NotNull(data);
            await modbus.WriteUShortAsync(MODBUS_SLAVE, 0, 2);

            data = await modbus.ReadUShortAsync(MODBUS_SLAVE, 0);

            Assert.NotNull(data);
            Assert.Equal((ushort)2, data);
            await modbus.WriteUShortAsync(MODBUS_SLAVE, 0, 0);

            data = await modbus.ReadUShortAsync(MODBUS_SLAVE, 0);

            Assert.NotNull(data);
            Assert.Equal((ushort)0, data);
            data = await modbus.ReadOnlyUShortAsync(MODBUS_SLAVE, 0);

            Assert.NotNull(data);
        }