首页 > 解决方案 > Windows 10 IoT - DeviceInformation.FindAllAsync() 返回空集合

问题描述

我正在尝试将 MPU-6050 (GY-521) 传感器与我的 Raspberry Pi 3 和 Windows 10 IoT 一起使用。我在 Hackster 上关注这个例子,但是下面一行

DeviceInformationCollection collection = await DeviceInformation.FindAllAsync(aqs);

返回一个空集合。我正在使用 Microsoft Lightning 提供程序。

这是aqs通过以下方式获得的字符串值I2cDevice.GetDeviceSelector()

System.Devices.InterfaceClassGuid:="{A11EE3C6-8421-4202-A3E7-B91FF90188E4}" AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True

标签: raspberry-piaccelerometeri2cwindows-10-iot-coregyroscope

解决方案


DMAP和收件箱驱动程序是相互排斥的。当通过设备门户启用 DMAP 驱动程序时,默认(收件箱)I2C 以及 SPI 和 GPIO 驱动程序被禁用。因此,您帖子中的上述代码将不起作用。请改用以下代码。

        if (LightningProvider.IsLightningEnabled)
        {
            LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider();
        }

        I2cController controller = await I2cController.GetDefaultAsync();

推荐阅读