简体   繁体   English

UWP:无法在Raspberry Pi 2上使用Lightning加载PWM控制器?

[英]UWP: Cannot load PWM Controllers using Lightning on Raspberry Pi 2?

i justed started working on an older Project i started once, but unfortunately the PWM Controller is not working anymore with the Lightning Driver. 我刚开始在一个较旧的项目上工作,但我刚开始,但是不幸的是,PWM控制器不再与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: 我正在使用Visual Studio 2017,RPi2运行在10.0.15063.414,并且已经安装了以下Nuget软件包:

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

The Project includes references to 该项目包括对

  • Analyzer 分析仪
  • Microsoft.IoT.Lightning Microsoft.IoT.Lightning
  • Microsoft.NETCore.UniversalWindowsPlatform Microsoft.NETCore.UniversalWindowsPlatform
  • %ClassesLibrary% %ClassesLibrary%
  • UniversalWindows UniversalWindows
  • Windows IoT Extensions for the UWP UWP的Windows IoT扩展
  • WinRTXamlToolkit.Controls.DataVisualization, WinRTXamlToolkit.Controls.DataVisualization,

where %ClassesLibrary% is an user-defined Project containing some classes for my Project. 其中%ClassesLibrary%是用户定义的项目,其中包含我的项目的某些类。 In the configuration web Interface of Windows IoT Core in the devices section, the Direct Memory Mapped Driver (Current Driver) is selected. 在设备部分的Windows IoT核心版的配置Web界面中,选择了直接内存映射驱动程序(当前驱动程序)。

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. PwmController.GetControllersAsync方法无法完成,我的应用程序无法启动。 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). 编辑:我还尝试了另一个示例( https://github.com/lprichar/WindowsIotPwmExample ),其中我用NuGet软件包(与我的项目中的版本相同)替换了嵌入式C / C ++闪电库。 The sample also Fails: the Pins are all null, because PwmController.GetControllersAsync never completes :-( 该示例也失败了:引脚全部为空,因为PwmController.GetControllersAsync从未完成:-(

EDIT2: I forgot to mention that my package.appxmanifest file also includes the following changes EDIT2:我忘了提及我的package.appxmanifest文件还包括以下更改

  <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>

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! 现在一切正常!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用MS-IoT Lightning设置/获取Raspberry Pi2的PWM? - How to use MS-IoT Lightning to set/get PWM with Raspberry Pi2? 无法将UWP应用部署到Raspberry Pi 3 - Cannot deploy UWP app to raspberry pi 3 语音识别在使用UWP的raspberry pi 3(Windows IoT核心版)中不起作用 - speech recognition not working in raspberry pi 3(windows iot core) using UWP UWP Raspberry Pi Webserver问题 - UWP Raspberry Pi Webserver issue UWP 在 Raspberry Pi 上使用 FullTrustesdLauncher 启动 EXE - UWP start EXE with FullTrustesdLauncher on Raspberry Pi 如何使用Windows 10 IoT(UWP)为Raspberry Pi 3创建可移植代码(.net标准2.0)? - How to create portable code (.net standard 2.0) for a Raspberry Pi 3 using Windows 10 IoT (UWP)? 使用UWP和C#刷新图像(Raspberry Pi3 Windows10 IoT) - Refresh an image using UWP and C# (Raspberry Pi3 Windows10 IoT) 使用I2c和IoT将字节从Raspberry Pi发送到Arduino以实现PWM - Sending Byte from Raspberry Pi to Arduino With I2c & IoT for PWM Raspberry Pi上的UWP中的颜色类(System.Drawing)问题 - Problems with Color class (System.Drawing) in UWP on Raspberry Pi 如何在 Raspberry PI 上使用 UWP 应用程序设置 SystemTime - How to use an UWP Application on Raspberry PI to set the SystemTime
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM