3

I'm trying to communicate between a Raspberry Pi 3 running Windows 10 IOT (build 14376 insiders) and a T-REX Manual here using I2C protocol. The thing is that it always crashes, so after some debugging I've found that it looks like it doesn't retrieve anything from the DeviceInformation.FinAllAsync(..) and that causes an ArgumentOutOfRangeException. It needs something I don't understand, maybe in the device capabilities or permissions, which the Microsoft tutorial here doesn't mention.

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

Then I have a:

using (I2cDevice device = await I2cDevice.FromIdAsync(dis[0].Id, settings)){...} 

which fails with the ArgumentOutOfRangeException mentioned before.

A second way I tried was using this code:

I2CDevice device;
var settings = new I2cConnectionSettings(0x07);
settings.BusSpeed = I2cBusSpeed.StandardMode;

var controller = await Windows.Devices.I2c.I2cController.GetDefaultAsync();
device = controller.GetDevice(settings);

which produces a NullReferenceException with the last line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.