Exception after TinyCLR RC update

Hi All,

Known good code on the previous release is now broken with the RC build.

How do I go about tracking down this generic exception?

#### Exception System.InvalidOperationException - CLR_E_INVALID_OPERATION (2) ####
#### Message: 
#### GHIElectronics.TinyCLR.IO.FileSystem::Initialize [IP: 0000] ####
#### GHIElectronics.TinyCLR.IO.FileSystem::Mount [IP: 0024] ####
#### XXXXX.TCLR.Common.World::SetupStorageController [IP: 0014] ####
#### XXXXX.TCLR.Common.World::.cctor [IP: 0012] ####
Exception thrown: 'System.InvalidOperationException' in GHIElectronics.TinyCLR.IO.dll
An unhandled exception of type 'System.InvalidOperationException' occurred in 
GHIElectronics.TinyCLR.IO.dll

Make sure SD card is still good or has connection well.

There is no change about SD Card from P6- to RC1

If I remove that line, I get similar errors at other places in the code… Such as the CanController

There were no changes to my code at all between updating from P6 to RC1. Any other ideas on how to diag this?

 #### Exception System.InvalidOperationException - CLR_E_INVALID_OPERATION (2) ####
#### Message: 
#### GHIElectronics.TinyCLR.Devices.Can.Provider.CanControllerApiWrapper::AddFilter [IP: 0000] ####
#### GHIElectronics.TinyCLR.Devices.Can.Filter::AddMaskFilter [IP: 000b] ####
#### xx.TCLR.Common.World::SetupCanController [IP: 0042] ####
#### xx.TCLR.Common.World::.cctor [IP: 000e] ####
Exception thrown: 'System.InvalidOperationException' in 
GHIElectronics.TinyCLR.Devices.Can.dll
An unhandled exception of type 'System.InvalidOperationException' occurred in 
GHIElectronics.TinyCLR.Devices.Can.dll
Uncaught exception

If you removed that line then SD won’t work.

For CAN, try to set the filter before Enable().

I only removed it for testing purposes.

Moving the filter before I call Enable sets the same exception. “System.InvalidOperationException”

Can I see your filter number id?

Or try some different number, something like

controller.Filter.AddMaskFilter(Filter.IdType.Standard, 0x100, 0x700);

Same exception, though this time on Enable. Same exception even if I move the filter after Enable.
.

Can you try simple

http://docs.ghielectronics.com/software/tinyclr/tutorials/can.html

Same result

EDIT: Erased, and reloaded the firmware. Same results. Rev A board

Move Enable(); to last.

Can’t add Filter once enabled. We will fix the doc.

var LdrButton = GpioController.GetDefault().OpenPin(SC20100.GpioPin.PE3);
        LdrButton.SetDriveMode(GpioPinDriveMode.InputPullUp);

        var can = CanController.FromName(SC20100.CanBus.Can1);

        var propagationPhase1 = 13;
        var phase2 = 2;
        var baudratePrescaler = 3;
        var synchronizationJumpWidth = 1;
        var useMultiBitSampling = false;

        can.SetNominalBitTiming(new CanBitTiming(propagationPhase1, phase2, baudratePrescaler,
            synchronizationJumpWidth, useMultiBitSampling));

        

        var message = new CanMessage()
        {
            Data = new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x2E, 0x20, 0x20 },
            ArbitrationId = 0x11,
            Length = 6,
            RemoteTransmissionRequest = false,
            ExtendedId = false,
            FdCan = false,
            BitRateSwitch = false
        };

        //The following filter will accept arbitration IDs from 0x12 to 0x20 inclusive.
        can.Filter.AddRangeFilter(Filter.IdType.Standard, 0x12, 0x20);

        //The following filter will accept arbitration IDs from 0x500 to 0x1000 inclusive.
        can.Filter.AddRangeFilter(Filter.IdType.Standard, 0x500, 0x1000);

        //The following filter will accept arbitration IDs of 0x11 and 0x13.
        can.Filter.AddMaskFilter(Filter.IdType.Standard, 0x11, 0xFD);

        //The following filter will accept arbitration IDs of 5678 only.
        can.Filter.AddMaskFilter(Filter.IdType.Standard, 0x5678, 0xFFFF);

        can.MessageReceived += Can_MessageReceived;
        can.ErrorReceived += Can_ErrorReceived;

        can.Enable();

        while (true)
        {
            if (LdrButton.Read() == GpioPinValue.Low)
                can.WriteMessage(message);

            Thread.Sleep(100);
        }

So, how can I change the filters during runtime?

Previously, I could add/remove hardware filters as needed. Now, it throws the exception each time that I attempt to add/remove during execution (post setup).

I attempted to disable change filters, then enable though no success.

Thanks

What do you mean no success, exception, filter doesn’t work?

I just tried, it should work.

controller.Enable();

// try disable to set filter
controller.Disable();

controller.Filter.AddRangeFilter(Filter.IdType.Extended, 10000, 10005); controller.Filter.AddMaskFilter(Filter.IdType.Standard, 0x100, 0x700);

// Enable again
controller.Enable();

You are correct. The issue detailed here was masking it: Have to clean solution each deployment

Thanks