jbienzms / iot-devices

Helper library for interfacing with devices in IoT projects.
45 stars 17 forks source link

Pwm/PCA9685.EnsureInitializedAsync() unable to throw exception #7

Closed mjmeans closed 7 years ago

mjmeans commented 8 years ago

So to repro the problem create a new UWP app. In app.xaml.cs in "Public App()" create a new PCA9685 object and then call its SetDesiredFrequency()).

Now run this on a Windows desktop machine that does NOT have an I2C1 device. When the program flow gets to EnsureInitializedAsync at the line "if (di == null) { throw new DeviceNotFoundException(controllerName); }" it should throw an exception because the device is not found. That doesn't happen. The app just hangs.

Could this be because of UISafeWait and that the UI isn't yet fully initialized? If so, then I think this is a design problem because typically on an IoT device you would want all hardware interfaces initialized during the time the splash screen is displayed.

jbienzms commented 7 years ago

Yes, there may be an issue here with the use of UISafeWait during app constructor. However, really none of the IoT APIs should be called from a desktop machine. In fact, you should use feature detection to determine if you should even attempt to access or initialize those APIs before calling them.

Please see this article and let me know if the issue still remains:

https://blogs.windows.com/buildingapps/2015/09/15/dynamically-detecting-features-with-api-contracts-10-by-10/

jbienzms commented 7 years ago

Assuming that this can be closed since it was impacting a desktop OS (where IoT isn't supported).