0

i justed started working on an older Project i started once, but unfortunately the PWM Controller is not working anymore with the Lightning Driver. I am using Visual Studio 2017, the RPi2 is running at 10.0.15063.414 and I've installed the following Nuget-Packages:

  • Microsoft.IoT.Lightning (v1.1.0)
  • Microsoft.NETCore.UniversalWindowsPlatform (v5.3.3)
  • WinRTXamlToolkit.Controls.DataVisualization (v2.3.0)

The Project includes references to

  • Analyzer
  • Microsoft.IoT.Lightning
  • Microsoft.NETCore.UniversalWindowsPlatform
  • %ClassesLibrary%
  • UniversalWindows
  • Windows IoT Extensions for the UWP
  • WinRTXamlToolkit.Controls.DataVisualization,

where %ClassesLibrary% is an user-defined Project containing some classes for my Project. In the configuration web Interface of Windows IoT Core in the devices section, the Direct Memory Mapped Driver (Current Driver) is selected.

My initialization Code Looks like this

    private static async Task InitOnboardHardware()
    {
        if (LightningProvider.IsLightningEnabled)
        {
            LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider();
            GpioController gpioController = GpioController.GetDefault();

            var pwmControllers = await PwmController.GetControllersAsync(LightningPwmProvider.GetPwmProvider());
            if (pwmControllers != null)
            {
                m_PWMController = pwmControllers[1];
                //m_PWMController = (await PwmController.GetControllersAsync(LightningPwmProvider.GetPwmProvider()))[1];
                m_PWMController.SetDesiredFrequency(100);

                m_RPin = m_PWMController.OpenPin(18);
                m_GPin = m_PWMController.OpenPin(23);
                m_BPin = m_PWMController.OpenPin(24);
                m_WPin = m_PWMController.OpenPin(25);

                m_RPin.SetActiveDutyCyclePercentage(0);
                m_GPin.SetActiveDutyCyclePercentage(0);
                m_BPin.SetActiveDutyCyclePercentage(0);
                m_WPin.SetActiveDutyCyclePercentage(0);

                m_RPin.Start();
                m_GPin.Start();
                m_BPin.Start();
                m_WPin.Start();

                m_IsHardwareInitialized = true;
            }
        }
    }

The PwmController.GetControllersAsync-method never completes and my application gets stuck on starting up. Also the commented Shorter Version is not working anymore?!

I have really no clue what i could be missing. Therefore, i would greatly appreciate any help.

Thank you in advance!

EDIT: I also tried another sample (https://github.com/lprichar/WindowsIotPwmExample), where i replaced the embedded C/C++ lightning library by the NuGet Package (same Version as in my Project). The sample also Fails: the Pins are all null, because PwmController.GetControllersAsync never completes :-(

EDIT2: I forgot to mention that my package.appxmanifest file also includes the following changes

  <Package
  xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
  xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
  xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10"
  IgnorableNamespaces="uap mp iot">

as well as

<Capabilities>
<Capability Name="internetClient" />
<iot:Capability Name="lowLevelDevices" />
<DeviceCapability Name="109b86ad-f53d-4b76-aa5f-821e2ddf2141" />
</Capabilities>
Roland
  • 133
  • 2
  • 12
  • I updated Windows IoT Core to the latest Insider build (10.0.16226.1000) and after that the sample was running fine, but my application was not. I compared each line and found out that the method for the GpioController has not been async. Changing it to an async method makes my application running fine! – Roland Jul 09 '17 at 20:32

1 Answers1

0

Please also see my comment to the first post. I had to Change this line

GpioController gpioController = GpioController.GetDefault();

to an async method call

GpioController gpioController = await GpioController.GetDefaultAsync();

and now everythings runs fine!

Roland
  • 133
  • 2
  • 12