private static void SetupHardwareAdapters(IServiceProvider serviceProvider)
        {
            var loggerFactory = serviceProvider.GetService <ILoggerFactory>();

            var i2CService  = serviceProvider.GetService <I2CBusService>();
            var gpioService = serviceProvider.GetService <GpioRegistryService>();

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                var i2CAdapter = new LinuxI2CBusAdapter(1, loggerFactory);
                i2CAdapter.Enable();
                i2CService.RegisterAdapter(string.Empty, i2CAdapter);

                var gpioAdapter = new LinuxGpioAdapter(loggerFactory);
                gpioAdapter.Enable();
                gpioService.RegisterAdapter(string.Empty, gpioAdapter);
            }
            else
            {
                var i2CAdapter = new TestI2CBusAdapter(loggerFactory);
                i2CService.RegisterAdapter(string.Empty, i2CAdapter);

                var gpioAdapter = new TestGpioAdapter(loggerFactory);
                gpioService.RegisterAdapter(string.Empty, gpioAdapter);
            }
        }
Beispiel #2
0
 public void Start()
 {
     if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
     {
         var gpioAdapter = new LinuxGpioAdapter(_logger);
         gpioAdapter.Enable();
         RegisterAdapter(string.Empty, gpioAdapter);
     }
     else
     {
         var gpioAdapter = new TestGpioAdapter(_logger);
         RegisterAdapter(string.Empty, gpioAdapter);
     }
 }
Beispiel #3
0
 protected override void OnStart()
 {
     if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
     {
         var gpioAdapter = new LinuxGpioAdapter(_systemStatusService, _logger);
         gpioAdapter.Enable();
         RegisterAdapter(string.Empty, gpioAdapter);
     }
     else
     {
         var gpioAdapter = new TestGpioAdapter(_logger);
         RegisterAdapter(string.Empty, gpioAdapter);
     }
 }