Main Site Documentation

Program raising an InvalidOperationException


#1

Guys,

I have a small FSM that drives a servo using PWM and a digital output on an extender board. The FSM cycles around 136 times and then an InvaldOperationException is raised. It seems impossible to debug with the knowledge I have and the result is very unexecpted. I could add a bunch of try-catch-finally blocks but thought I’d see if anyone had any experience of this kind of error and could point me in the right direction.


Found debugger!

Create TS.

 Loading start at a0e00000, end a0e1383c

   Assembly: mscorlib (4.2.0.0)     Assembly: Microsoft.SPOT.Native (4.2.0.0)     Assembly: Microsoft.SPOT.Security.PKCS11 (4.2
.0.0)     Assembly: System.Security (4.2.0.0)  Loading Deployment Assemblies.

Attaching deployed file.

   Assembly: Microsoft.SPOT.IO (4.2.0.0)  Attaching deployed file.

   Assembly: Gadgeteer (2.42.0.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Graphics (4.2.0.0)  Attaching deployed file.

   Assembly: Blade lifecycle testing (1.0.0.0)  Attaching deployed file.

   Assembly: System.Http (4.2.0.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Hardware (4.2.0.0)  Attaching deployed file.

   Assembly: System (4.2.0.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Net.Security (4.2.0.0)  Attaching deployed file.

   Assembly: GTM.GHIElectronics.Extender (1.1.2.0)  Attaching deployed file.

   Assembly: GHI.Premium.Hardware (4.2.7.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Touch (4.2.0.0)  Attaching deployed file.

   Assembly: GTM.GHIElectronics.UsbClientDP (1.1.1.0)  Attaching deployed file.

   Assembly: GTM.GHIElectronics.Button (1.1.1.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.TinyCore (4.2.0.0)  Attaching deployed file.

   Assembly: GHI.Premium.System (4.2.7.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Net (4.2.0.0)  Attaching deployed file.

   Assembly: System.IO (4.2.0.0)  Attaching deployed file.

   Assembly: GHI.Premium.IO (4.2.7.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Hardware.PWM (4.2.0.1)  Attaching deployed file.

   Assembly: System.Net.Security (4.2.0.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Hardware.SerialPort (4.2.0.0)  Attaching deployed file.

   Assembly: GHIElectronics.Gadgeteer.FEZSpider (1.1.1.0)  Resolving.

GC: 1msec 36048 bytes used, 7303620 bytes available

Type 0F (STRING              ):     24 bytes

Type 15 (FREEBLOCK           ): 7303620 bytes

Type 17 (ASSEMBLY            ):  31908 bytes

Type 1E (BINARY_BLOB_HEAD    ):   4044 bytes

Type 34 (APPDOMAIN_HEAD      ):     72 bytes

GC: performing heap compaction...

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\mscorlib.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Native.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Security.PKCS11.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Security.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.IO.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Net.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Graphics.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.TinyCore.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.IO.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.PWM.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Gadgeteer\Core\Assemblies\.NET Micro Framework 4.2\le\Gadgeteer.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\Button\NETMF 4.2\le\GTM.GHIElectronics.Button.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\Extender\NETMF 4.2\le\GTM.GHIElectronics.Extender.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\UsbClientDP\NETMF 4.2\le\GTM.GHIElectronics.UsbClientDP.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.System.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.IO.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.Hardware.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI .NET Gadgeteer SDK\Mainboards\FEZSpider\NETMF 4.2\le\GHIElectronics.Gadgeteer.FEZSpider.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Users\JJames\Documents\Visual Studio 2010\Projects\Automation\Handtool\Blade lifecycle testing\Blade lifecycle testing\bin\Release\le\Blade lifecycle testing.exe', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Net.Security.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Net.Security.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Http.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Touch.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.SerialPort.dll', Symbols loaded.
The thread '<No Name>' (0x2) has exited with code 0 (0x0).
Using mainboard GHI Electronics FEZSpider version 1.0
Program Started
Servo Stopped
Blade Up
Awaiting button press
OP # - 1
OP # - 2
OP # - 3
OP # - 4
The thread '<No Name>' (0x3) has exited with code 0 (0x0).
OP # - 5
OP # - 6
...
OP # - 135
OP # - 136
GC: 135msec 89484 bytes used, 7250184 bytes available
Type 0F (STRING              ):   1380 bytes
Type 11 (CLASS               ):  23892 bytes
Type 12 (VALUETYPE           ):   1512 bytes
Type 13 (SZARRAY             ):   4500 bytes
  Type 03 (U1                  ):    156 bytes
  Type 04 (CHAR                ):    852 bytes
  Type 07 (I4                  ):   1044 bytes
  Type 0F (STRING              ):     72 bytes
  Type 11 (CLASS               ):   2292 bytes
  Type 12 (VALUETYPE           ):     84 bytes
Type 15 (FREEBLOCK           ): 7250184 bytes
Type 16 (CACHEDBLOCK         ):    120 bytes
Type 17 (ASSEMBLY            ):  31908 bytes
Type 18 (WEAKCLASS           ):     96 bytes
Type 19 (REFLECTION          ):    168 bytes
Type 1B (DELEGATE_HEAD       ):    756 bytes
Type 1D (OBJECT_TO_EVENT     ):    288 bytes
Type 1E (BINARY_BLOB_HEAD    ):  14268 bytes
Type 1F (THREAD              ):   1536 bytes
Type 20 (SUBTHREAD           ):    144 bytes
Type 21 (STACK_FRAME         ):   1632 bytes
Type 22 (TIMER_HEAD          ):    144 bytes
Type 26 (WAIT_FOR_OBJECT_HEAD):     48 bytes
Type 27 (FINALIZER_HEAD      ):   3432 bytes
Type 31 (IO_PORT             ):    216 bytes
Type 34 (APPDOMAIN_HEAD      ):     72 bytes
Type 36 (APPDOMAIN_ASSEMBLY  ):   3372 bytes
    #### Exception System.InvalidOperationException - CLR_E_INVALID_OPERATION (6) ####
    #### Message: 
    #### Microsoft.SPOT.Hardware.Port::ReservePin [IP: 0000] ####
    #### Microsoft.SPOT.Hardware.PWM::Dispose [IP: 0017] ####
A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.dll
An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.dll


The code looks like this:


using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using Gadgeteer.Interfaces;

namespace Blade_lifecycle_testing
{

    public enum FSM
    {
        BladeUp,
        Wait_BladeUp,
        WireMoveStart,
        Wait_WireMoveStart,
        WireMoveStop,
        Wait_WireMoveStop,
        BladeDown,
        Wait_BladeDown
    }

    public partial class Program
    {
        FSM MachineState;
        GT.Timer MachineTimer;
        uint period = 20 * 1000 * 1000;
        uint high1 = 1400 * 1000;
        PWMOutput servo;
        DigitalOutput blade;
        uint ServoRunTime = 50;
        uint ServoWaitTime = 150;
        uint BladeDownTime = 100;
        uint BladeUpTime = 100;
        uint ticks = 0;
        bool TimerEnabled = false;
        uint operations = 0;
        bool DebugPrint = false;

        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            Debug.Print("Program Started");

            MachineState = FSM.WireMoveStart;
            MachineTimer = new GT.Timer(1);
            MachineTimer.Tick += new GT.Timer.TickEventHandler(MachineTimer_Tick);

            button.ButtonReleased += new Button.ButtonEventHandler(button_ButtonReleased);
            servo = extender.SetupPWMOutput(GT.Socket.Pin.Eight);
            servo.SetPulse(period, high1); 
            servo.Active = false;
            Debug.Print("Servo Stopped");

            blade = extender.SetupDigitalOutput(GT.Socket.Pin.Three, false);
            blade.Write(false);
            Debug.Print("Blade Up");

            Debug.Print("Awaiting button press");
        }

        void button_ButtonReleased(Button sender, Button.ButtonState state)
        {
            if (TimerEnabled)
            {
                TimerEnabled = false;
                servo.Active = false;

                MachineTimer.Stop();
            }
            else
            {
                TimerEnabled = true;
                MachineTimer.Start();
            }
        }

        void MachineTimer_Tick(GT.Timer timer)
        {
            ProcessMachineState();
        }

        private void ProcessMachineState()
        {
            switch (MachineState)
            {
                case FSM.WireMoveStart:
                    {
                        if(DebugPrint)
                            Debug.Print("WireMoveStart");
                        StartWireMove();
                        ticks = 0;
                        MachineState = FSM.Wait_WireMoveStart;
                        operations++;
                        Debug.Print("OP # - " + operations.ToString());
                        break;
                    }
                case FSM.Wait_WireMoveStart:
                    {
                        if (DebugPrint)
                            Debug.Print("Wait_WireMoveStart\t\t" + ticks.ToString());
                        ticks++;
                        if (ticks == ServoRunTime)
                        {
                            MachineState = FSM.WireMoveStop;
                        }
                        break;
                    }
                case FSM.WireMoveStop:
                    {
                        if (DebugPrint)
                            Debug.Print("WireMoveStop");
                        StopWireMove();
                        ticks = 0;
                        MachineState = FSM.Wait_WireMoveStop;
                        break;
                    }
                case FSM.Wait_WireMoveStop:
                    {
                        if (DebugPrint)
                            Debug.Print("Wait_WireMoveStop\t\t" + ticks.ToString());
                        ticks++;
                        if(ticks == ServoWaitTime)
                        {
                            MachineState = FSM.BladeDown;
                        }
                        break;
                    }
                case FSM.BladeDown:
                    {
                        if (DebugPrint)
                            Debug.Print("BladeDown");
                        BladeDown();
                        ticks = 0;
                        MachineState = FSM.Wait_BladeDown;
                        break;
                    }
                case FSM.Wait_BladeDown:
                    {
                        if (DebugPrint)
                            Debug.Print("Wait_BladeDown\t\t" + ticks.ToString());
                        ticks++;
                        if (ticks == BladeDownTime)
                        {
                            MachineState = FSM.BladeUp;
                        }
                        break;
                    }
                case FSM.BladeUp:
                    {
                        if (DebugPrint)
                            Debug.Print("BladeDown");
                        BladeUp();
                        ticks = 0;
                        MachineState = FSM.Wait_BladeUp;
                        break;
                    }
                case FSM.Wait_BladeUp:
                    {
                        if (DebugPrint)
                            Debug.Print("Wait_BladeUp\t\t" + ticks.ToString());
                        ticks++;
                        if (ticks == BladeUpTime)
                        {
                            MachineState = FSM.WireMoveStart;
                        }
                        break;
                    }
            }
        }

        private void StartWireMove()
        {
            servo.Active = true;
        }

        private void StopWireMove()
        {
            servo.Active = false;
        }

        private void BladeDown()
        {
            blade.Write(true);
        }

        private void BladeUp()
        {
            blade.Write(false);
        }
    }
}

Many thanks,

Jason.


#2

It looks like your PWM got disposed, but I don’t see how that could happen. Can you set your timer interval to lets say 100, not 1?


#3

Architect, even increasing it to 10 seemed to do the trick. I’ll leave it running for a while to see if it fails at some point and post back with my news.

Many thanks,

J.


#4

Yeah, using 1ms for a timer was not good. Glad that helped.


#5

Architect, I upped the timer to 100ms and managed 1201 cycles of my FSM and then I got the same error. Do you have any other thoughts why the my PWM object is falling out of scope; it is declared with class level scope? Can you think of any other way of getting around the problem?

Many thanks,

J.


#6

extender is a Gadgeteer module connected to socket 11 on my Spider. I’ve looked at the schematic and then used a hardware PWM output from that socket.


#7

GHI SDK or NETMF? I thought I had the latest of everything.

J.


#8

GHI SDK = 4.2.9, you seem to have 4.2.7


#9

Brett,

do you have a link for the latest version please?

J.


#10

Yep, thanks to @ Architect in another post :slight_smile:
http://www.ghielectronics.com/download/ghi-software-package-v4.2-02142013

Gus said the website change today dropped off the latest link; it’ll get corrected in the morning.


#11

Brett,

many thanks. Downloading now. I’ll post once I’ve updated to let you know if this fixes the issue I have.

J.


#12

Guys,

we got to 2.5k with the timer tick every 50ms using 4.2.9 of the SDK but eventually an unhandled exception was raised.

Amy more thoughts that might help me out?


Found debugger!

Create TS.

 Loading start at a0e00000, end a0e1383c

   Assembly: mscorlib (4.2.0.0)     Assembly: Microsoft.SPOT.Native (4.2.0.0)     Assembly: Microsoft.SPOT.Security.PKCS11 (4.2
.0.0)     Assembly: System.Security (4.2.0.0)  Loading Deployment Assemblies.

Attaching deployed file.

   Assembly: Microsoft.SPOT.IO (4.2.0.0)  Attaching deployed file.

   Assembly: Gadgeteer (2.42.0.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Graphics (4.2.0.0)  Attaching deployed file.

   Assembly: Blade lifecycle testing (1.0.0.0)  Attaching deployed file.

   Assembly: System.Http (4.2.0.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Hardware (4.2.0.0)  Attaching deployed file.

   Assembly: System (4.2.0.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Net.Security (4.2.0.0)  Attaching deployed file.

   Assembly: GTM.GHIElectronics.Extender (1.1.2.0)  Attaching deployed file.

   Assembly: GHI.Premium.Hardware (4.2.9.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Touch (4.2.0.0)  Attaching deployed file.

   Assembly: GTM.GHIElectronics.UsbClientDP (1.1.1.0)  Attaching deployed file.

   Assembly: GTM.GHIElectronics.Button (1.1.1.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.TinyCore (4.2.0.0)  Attaching deployed file.

   Assembly: GHI.Premium.System (4.2.9.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Net (4.2.0.0)  Attaching deployed file.

   Assembly: System.IO (4.2.0.0)  Attaching deployed file.

   Assembly: GHI.Premium.IO (4.2.9.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Hardware.PWM (4.2.0.1)  Attaching deployed file.

   Assembly: System.Net.Security (4.2.0.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Hardware.SerialPort (4.2.0.0)  Attaching deployed file.

   Assembly: GHIElectronics.Gadgeteer.FEZSpider (1.1.1.0)  Resolving.

GC: 1msec 36108 bytes used, 7303560 bytes available

Type 0F (STRING              ):     24 bytes

Type 15 (FREEBLOCK           ): 7303560 bytes

Type 17 (ASSEMBLY            ):  31968 bytes

Type 1E (BINARY_BLOB_HEAD    ):   4044 bytes

Type 34 (APPDOMAIN_HEAD      ):     72 bytes

GC: performing heap compaction...

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\mscorlib.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Native.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Security.PKCS11.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Security.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.IO.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Net.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Graphics.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.TinyCore.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.IO.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.PWM.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Gadgeteer\Core\Assemblies\.NET Micro Framework 4.2\le\Gadgeteer.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\Button\NETMF 4.2\le\GTM.GHIElectronics.Button.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\Extender\NETMF 4.2\le\GTM.GHIElectronics.Extender.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\UsbClientDP\NETMF 4.2\le\GTM.GHIElectronics.UsbClientDP.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.System.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.IO.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.Hardware.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI .NET Gadgeteer SDK\Mainboards\FEZSpider\NETMF 4.2\le\GHIElectronics.Gadgeteer.FEZSpider.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Users\JJames\Documents\Visual Studio 2010\Projects\Automation\Handtool\Blade lifecycle testing\Blade lifecycle testing\bin\Release\le\Blade lifecycle testing.exe', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Net.Security.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Net.Security.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Http.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Touch.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.SerialPort.dll', Symbols loaded.
The thread '<No Name>' (0x2) has exited with code 0 (0x0).
Using mainboard GHI Electronics FEZSpider version 1.0
Program Started
Servo Stopped
Blade Up
Awaiting button press
OP # - 1
OP # - 2
OP # - 3
...
OP # - 2532
GC: 205msec 348336 bytes used, 6991332 bytes available
Type 0F (STRING              ):   1380 bytes
Type 11 (CLASS               ): 225156 bytes
Type 12 (VALUETYPE           ):   1512 bytes
Type 13 (SZARRAY             ):   4452 bytes
  Type 03 (U1                  ):    156 bytes
  Type 04 (CHAR                ):    852 bytes
  Type 07 (I4                  ):   1044 bytes
  Type 0F (STRING              ):     72 bytes
  Type 11 (CLASS               ):   2244 bytes
  Type 12 (VALUETYPE           ):     84 bytes
Type 15 (FREEBLOCK           ): 6991332 bytes
Type 16 (CACHEDBLOCK         ):    120 bytes
Type 17 (ASSEMBLY            ):  31968 bytes
Type 18 (WEAKCLASS           ):     96 bytes
Type 19 (REFLECTION          ):    168 bytes
Type 1B (DELEGATE_HEAD       ):    756 bytes
Type 1D (OBJECT_TO_EVENT     ):    288 bytes
Type 1E (BINARY_BLOB_HEAD    ):  14340 bytes
Type 1F (THREAD              ):   1536 bytes
Type 20 (SUBTHREAD           ):    144 bytes
Type 21 (STACK_FRAME         ):   1632 bytes
Type 22 (TIMER_HEAD          ):    144 bytes
Type 26 (WAIT_FOR_OBJECT_HEAD):     48 bytes
Type 27 (FINALIZER_HEAD      ):  60936 bytes
Type 31 (IO_PORT             ):    216 bytes
Type 34 (APPDOMAIN_HEAD      ):     72 bytes
Type 36 (APPDOMAIN_ASSEMBLY  ):   3372 bytes
    #### Exception System.InvalidOperationException - CLR_E_INVALID_OPERATION (6) ####
    #### Message: 
    #### Microsoft.SPOT.Hardware.Port::ReservePin [IP: 0000] ####
    #### Microsoft.SPOT.Hardware.PWM::Dispose [IP: 0017] ####
A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.dll
An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.dll



#13

Andre,

this is getting a little beyond my levels of experience with Gadgetter. Whilst I’m not asking you to write it for me, do you have any examples or other posts that I might use as a basis for what you are suggesting?

Thanks,

Jason.


#14

Here is the current Program.generated.cs file contents. I’ll post my new one once I’ve implemented the new module class.



//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by the Gadgeteer Designer.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using Gadgeteer;
using GTM = Gadgeteer.Modules;

namespace Blade_lifecycle_testing
{
    public partial class Program : Gadgeteer.Program
    {
        // GTM.Module definitions
        Gadgeteer.Modules.GHIElectronics.Extender extender;
        Gadgeteer.Modules.GHIElectronics.UsbClientDP usbClientDP;
        Gadgeteer.Modules.GHIElectronics.Button button;

        public static void Main()
        {
            //Important to initialize the Mainboard first
            Mainboard = new GHIElectronics.Gadgeteer.FEZSpider();			

            Program program = new Program();
            program.InitializeModules();
            program.ProgramStarted();
            program.Run(); // Starts Dispatcher
        }

        private void InitializeModules()
        {   
            // Initialize GTM.Modules and event handlers here.		
            usbClientDP = new GTM.GHIElectronics.UsbClientDP(1);
		
            button = new GTM.GHIElectronics.Button(4);
		
            extender = new GTM.GHIElectronics.Extender(11);

        }
    }
}


#15

You don’t really need a new class you can work with PWM directly.


#16

I am just saying if he is adding/changing extender class he might as well get rid off it


#17

@ Jason - Don’t use extender or/and PWMOutput from Gadgeteer Core there is a bug in it. Use PWM from plain NETMF


#18

Yes, I would use PWM directly.


#19

Talking about different cores here.


#20

Guys,

thanks for sticking with me on this. I’ve implemented the changes, although I am still using extender for the blade at present, just not the PWM. All seems happy and is working as I expected. I’m going to leave it to run now and will post back tomorrow with where it got to.

Very much appreciated.

Jason.