def start(self): """ """ # Todo: Improve error handling. try: # Vanilla MicroPython 1.11 if self.platform_info.vendor == self.platform_info.MICROPYTHON.Vanilla: pin = Pin(int(self.pins['data'][1:])) import onewire_native self.adapter = onewire_native.OneWire(pin) # Pycom MicroPython 1.9.4 elif self.platform_info.vendor == self.platform_info.MICROPYTHON.Pycom: pin = Pin(self.pins['data']) if self.settings.get('driver') == 'native': log.info('Using native 1-Wire driver on Pycom MicroPython') import onewire_native self.adapter = onewire_native.OneWire(pin) else: log.info( 'Using pure-Python 1-Wire driver on Pycom MicroPython') import onewire_python self.adapter = onewire_python.OneWire(pin) else: raise NotImplementedError( '1-Wire driver not implemented on this platform') self.scan_devices() except Exception as ex: log.exc(ex, '1-Wire hardware driver failed') return False return True
def start(self): """ """ # Todo: Improve error handling. try: # Vanilla MicroPython 1.11 if self.platform_info.vendor == self.platform_info.MICROPYTHON.Vanilla: pin = Pin(int(self.pins['data'][1:])) import onewire_native self.adapter = onewire_native.OneWire(pin) # Pycom MicroPython 1.9.4 elif self.platform_info.vendor == self.platform_info.MICROPYTHON.Pycom: pin = Pin(self.pins['data']) if self.settings.get('driver') == 'native': log.info('Using native 1-Wire driver on Pycom MicroPython') import onewire_native self.adapter = onewire_native.OneWire(pin) else: log.info( 'Using pure-Python 1-Wire driver on Pycom MicroPython') import onewire_python self.adapter = onewire_python.OneWire(pin) elif self.platform_info.vendor == self.platform_info.MICROPYTHON.RaspberryPi: from terkin.sensor.linux import LinuxSysfsOneWireBus sysfs = self.settings['sysfs'] self.adapter = LinuxSysfsOneWireBus(sysfs) else: raise NotImplementedError( '1-Wire bus support is not implemented on this platform') self.scan_devices() self.ready = True except Exception as ex: #log.exc(ex, '1-Wire hardware driver failed') #return False raise return True