Beispiel #1
0
        public async Task TestBool()
        {
            var           factory = new ModbusFactory();
            IModbusMaster modbus  = factory.CreateMaster(_client);
            await _client.ConnectAsync(MODBUS_IP, MODBUS_PORT);

            bool?data = await modbus.ReadBoolAsync(MODBUS_SLAVE, 0);

            Assert.NotNull(data);
            await modbus.WriteBoolAsync(MODBUS_SLAVE, 0, true);

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

            Assert.NotNull(data);
            Assert.True(data);
            await modbus.WriteBoolAsync(MODBUS_SLAVE, 0, false);

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

            Assert.NotNull(data);
            Assert.False(data);
            data = await modbus.ReadOnlyBoolAsync(MODBUS_SLAVE, 0);

            Assert.NotNull(data);
        }