DexterInd / GrovePi

GrovePi is an open source platform for connecting Grove Sensors to the Raspberry Pi.
https://www.dexterindustries.com/grovepi/
Other
490 stars 486 forks source link

AggregateException was unhandled by user code in C# Project #221

Open dougseven opened 8 years ago

dougseven commented 8 years ago

Anyone else facing this:

I pulled down a clone of the GrovePi repo today and went to build a simple Blinky app in C# (using a Windows IoT Background Application template).

Everything builds fine, but when I try to run on Remote Machine and point to my RPi2, I get an AggregteException at the line of code indicated by my comment (DeviceFactory.cs lines 175-183):

private GrovePi BuildGrovePiImpl(int address)
{
    if (_device != null)
    {
        return _device;
    }

    /* Initialize the I2C bus */
    var settings = new I2cConnectionSettings(address)
    {
        BusSpeed = I2cBusSpeed.StandardMode
    };

    _device = Task.Run(async () =>
    {
        var dis = await GetDeviceInfo();

        // Create an I2cDevice with our selected bus controller and I2C settings
        var device = await I2cDevice.FromIdAsync(dis[0].Id, settings);
        return new GrovePi(device);
   }).Result; // EXCEPTION OCCURRED HERE
   return _device;
}

There is NO I2C jack in use - the only thing plugged into the GrovePi shield is an LED module in port D5 (I have also tried D4 to rule out the port). The code that is apparently invoking the above code is led = DeviceFactory.Build.Led(Pin.DigitalPin5);

Here is the call stack

GrovePi.dll GrovePi.DeviceBuilder.BuildGrovePiImpl(int address) Line 175
GrovePi.dll GrovePi.DeviceBuilder.DoBuild<GrovePi.Sensors.Led>(System.Func<GrovePi.GrovePi, GrovePi.Sensors.Led> factory) Line 158
GrovePi.dll GrovePi.DeviceBuilder.Led(GrovePi.Pin pin) Line 68
Blinky.winmd Blinky.StartupTask.Run(Windows.ApplicationModel.Background.IBackgroundTaskInstance taskInstance) Line 58

Here is the exception info

An exception of type 'System.AggregateException' occurred in mscorlib.ni.dll but was not handled in user code

System.AggregateException was unhandled by user code
  HResult=-2146233088
  Message=One or more errors occurred.
  Source=mscorlib
  StackTrace:
       at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
       at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
       at System.Threading.Tasks.Task`1.get_Result()
       at GrovePi.DeviceBuilder.BuildGrovePiImpl(Int32 address)
       at GrovePi.DeviceBuilder.DoBuild[TSensor](Func`2 factory)
       at GrovePi.DeviceBuilder.Led(Pin pin)
       at Blinky.StartupTask.Run(IBackgroundTaskInstance taskInstance)
  InnerException: 
       ErrorCode=-2147024865
       HResult=-2147024865
       Message=A device attached to the system is not functioning.

Failed to apply connection settings to the device.
       Source=""
       StackTrace:
            at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
            at GrovePi.DeviceBuilder.<>c__DisplayClass30_0.<<BuildGrovePiImpl>b__0>d.MoveNext()
       InnerException: 
DexterInd commented 8 years ago

@dougseven still having this problem?