[IoTCore] [UWP]如何检查后台任务中的gpio状态,而其他正在运行的应用程序可以访问它 [英] [IoTCore][UWP] How to check the gpio state in a background task while other running apps can access it
问题描述
使用Windows 10 IoT核心我需要在Raspberry PI上监控GPIO,同时运行我无法控制的各种应用程序。
更详细我想创建一个后台任务可以循环读取gpio引脚的状态(无论是高逻辑电平还是低逻辑电平,可能还有输入或输出模式)。后台任务应该能够与使用gpio跟踪其gpio使用的任何其他
前台应用程序同时工作。
创建gpio监视器的主要问题是应用程序写入引脚分配gpio独占模式而不释放它,因此即使在只读模式下也无法连接到gpio ...例如,如果app
使用此标准代码写入一个引脚:
Using Windows 10 IoT Core I need to monitoring the GPIO on Raspberry PI while it's running various apps I can not control.
More in detail I would like to create a background task that can read cyclically the status of the gpio pins (whether at a high or low logic level and possibly in input or output mode). The background task should be able to work simultaneously with any other
foreground app that uses gpio to track its gpio use.
The main problem for creating the gpio monitor is that the apps to write on the pins allocate the gpio in exclusive mode without ever releasing it and so it becomes impossible to connect to gpio even in read-only mode... for example if an app
uses this standard code to write to a pin:
var pin = GpioController.GetDefault().OpenPin(PIN_NUMBER);
GpioSharingMode.SharedReadOnly);
pin.Write(GpioPinValue.High);
pin.SetDriveMode(GpioPinDriveMode.Output);
// And "pin" will never be released...
在这种情况下,另一项任务可以检查每个gpio-pin的状态任何时候?
你有什么想法吗?
In this scenario can another task be able to examine the status of each gpio-pin at any time?
Do you have some ideas?
非常感谢您的支持
Thank you so much for the support
推荐答案
可能的解决方案是使用应用服务,允许跨应用共享数据和功能
a possible solution could be the usage of app services which allows to share data and functionality across apps
更多有关使用应用服务的信息
这篇关于[IoTCore] [UWP]如何检查后台任务中的gpio状态,而其他正在运行的应用程序可以访问它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!