[英]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软件包:
The Project includes references to 该项目包括对
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.