OneWireReset() public method

Reset the 1-Wire bus and return the presence of any device
public OneWireReset ( ) : bool
return bool
        void GetConnectedOneWireDevices()
        {
            _oneWireDevices = new List <IOneWireDevice>();
            var first          = true;
            var deviceDetected = _ds2482_100.OneWireReset();

            if (deviceDetected)
            {
                var result = true;
                do
                {
                    if (first)
                    {
                        first  = false;
                        result = _ds2482_100.OneWireFirst();
                    }
                    else
                    {
                        result = _ds2482_100.OnoWireNext();
                    }

                    if (result)
                    {
                        AddOneWireDevice();
                    }
                } while (result);
            }
        }
        /// <summary>
        /// One wire device handler via DS2482-100
        /// </summary>
        /// <param name="ad0">AD0 addess bit</param>
        /// <param name="ad1">AD1 addess bit</param>
        /// <exception cref="Rinsen.IoT.OneWire.DS2482100DeviceNotFoundException">Thrown if no DS2482-100 device is detected</exception>
        public OneWireDeviceHandler(bool ad0 = true, bool ad1 = true)
        {
            byte address = 0x18;

            if (ad0)
            {
                address |= 1 << 0;
            }
            if (ad1)
            {
                address |= 1 << 1;
            }

            _ds2482_100 = new DS2482_100(new I2cDeviceLocator().GetI2cDevice(address));

            try
            {
                _ds2482_100.OneWireReset();
            }
            catch (Exception e)
            {
                throw new DS2482100DeviceNotFoundException("No DS2482-100 detected, check that AD0 and AD1 is correct in ctor and that the physical connection to the DS2482-100 one wire bridge is correct.", e);
            }

            _oneWireDeviceTypes = new Dictionary <byte, Type>();

            AddDeviceType <DS18S20>(0x10);
            AddDeviceType <DS18B20>(0x28);
        }
Example #3
0
        void ResetOneWireAndMatchDeviceRomAddress()
        {
            DS2482_100.OneWireReset();

            DS2482_100.OneWireWriteByte(RomCommand.MATCH);

            foreach (var item in OneWireAddress)
            {
                DS2482_100.OneWireWriteByte(item);
            }
        }
Example #4
0
        private static DS2482_100 PrivateCreateDs2482_100(I2cDevice i2cDevice, bool disposeI2cDevice)
        {
            var ds2482_100 = new DS2482_100(i2cDevice, disposeI2cDevice);

            try
            {
                ds2482_100.OneWireReset();
            }
            catch (Exception e)
            {
                throw new DS2482100DeviceNotFoundException("No DS2482-100 detected, check that AD0 and AD1 is correct in ctor and that the physical connection to the DS2482-100 one wire bridge is correct.", e);
            }

            return(ds2482_100);
        }