我尝试在运行 Windows 10 IOT build 14376 内部人员的树莓派 3 和此处使用 I2C 协议的 T-REX手册之间进行通信。DeviceInformation.FinAllAsync(..)
问题是它总是崩溃,所以经过一些调试过程后,我发现它似乎没有从ArgumentOutOfRangeException
. 它应该有一些我不明白的东西,可能在设备功能或权限中,微软教程在这里没有提到
var settings = new I2cConnectionSettings(0x07);
settings.BusSpeed = I2cBusSpeed.StandardMode;
var aqs = I2cDevice.GetDeviceSelector("I2C1");
var dis = await DeviceInformation.FindAllAsync(aqs);
int a = dis.Count; //is always equal to 0
然后我有一个前面提到的using (I2cDevice device = await I2cDevice.FromIdAsync(dis[0].Id, settings)){...}
失败ArgumentOutOfRangeException
我尝试的第二种方法是使用此代码:
I2CDevice device;
var settings = new I2cConnectionSettings(0x07);
settings.BusSpeed = I2cBusSpeed.StandardMode;
var controller = await Windows.Devices.I2c.I2cController.GetDefaultAsync();
device = controller.GetDevice(settings);
NullReferenceException
最后一行产生 a