Main Site Documentation

Spider SD Card event not raised when T35 Display is present


#1

Hello guys,
Spider version 4.1.7.0

if you have an SD Card and the T35 Display plugged in and configured via the designer… for some reason the SD Card Mounted Event never gets raised upon boot… while the card is in the slot…

here is the code:

 
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            sdCard.SDCardMounted += new SDCard.SDCardMountedEventHandler(sdCard_SDCardMounted);
            button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);

            Debug.Print("Program Started");
        }

when stepping thought the code i noticed that the even in SDCard.cs get called but SDCardMounted is null…


        /// <summary>
        /// Raises the <see cref="SDCardMounted"/> event.
        /// </summary>
        /// <param name="sender">The <see cref="SDCard"/> object that raised the event.</param>
        /// <param name="SDCard">A storage device that can be used to access the SD non-volatile memory card.</param>
        protected virtual void OnSDCardMountedEvent(SDCard sender, StorageDevice SDCard)
        {
            if (_OnSDCardMounted == null) _OnSDCardMounted = new SDCardMountedEventHandler(OnSDCardMountedEvent);
            if (Program.CheckAndInvoke([b]SDCardMounted[/b], _OnSDCardMounted, sender, SDCard))
            {
                SDCardMounted(sender, SDCard);
            }
        }

this is SDCardMounted null which is why it never raises the event.

removing the Display causes the event to raise as it should.

PS: the event works when you physically remove and reinsert the card. so the above fails when the system recycles power…

THIS IS A BUG since the SD card even will never be accessed if i reboot the system…

cheers,
Jay


#2

I don’t think the 4.1.7.0 is the Gadgeteer SDK release number. More likely it is the GHI SDK number.

The latest GHI SDK number is 4.1.8.0. si I suggest you update your firmware.

Also, are you using a powered USB hub?

I would have to check the code, but is it possible that the SD driver has already mounted the SD before you had a chance to subscribe to the event?


#3

Hi Mike,
thanks for the reply.
the 4.1.7.0 is what i see in the T35 Display when it boots up…
so i did some more digging and here is what i found out…

basically if i have ONLY The SD CARD and the DP Module Physically plugged, and properly assigned in the Graphic Designer… the event gets raised…

now if i add a button in the graphic designer and connect it to any of the following Sockets 6, 8, 9, 10, 11, 12 or 14… without physically attaching it… and ran the program the even is never raised…
if i add the button to Socket 4 the event is raised properly… so this issue is related to anything attached to Sockets 6, 8, 9, 10, 12, 11 and or 14.

anyone else can confirm…

here are the steps …

open a Gadgeteer project.
add the USBClientDP Module to Socket 1 and a Button to Socket 12 and an SD Card to Socket 5 (remember to stick a card in the sd module)… now copy and past the code below:


   void ProgramStarted()
        {            
            sdCard.SDCardMounted += new SDCard.SDCardMountedEventHandler(sdCard_SDCardMounted);
            sdCard.SDCardUnmounted += new SDCard.SDCardUnmountedEventHandler(sdCard_SDCardUnmounted);
}

        void sdCard_SDCardMounted(SDCard sender, StorageDevice SDCard)
        {
            Debug.Print("Mounted");
            for (int i = 0; i < 50; i++)
            {
                Thread.Sleep(100);
                 PulseDebugLED();  //turns on the LED on the spider board.
            }                       
        }

        void sdCard_SDCardUnmounted(SDCard sender)
        {
            Debug.Print("unmounted");
        }


now deploy and watch the debugger when the application starts the event is not raised and the LED never turns on…

now go back to the Graphic designer and disconnect the button from Socket 12 and connect it to Socket 4. Deploy and debug and voila the event is raised and the LED is on…

please confirm if you have similar issues…

my Guess is that any module that gets plugged in to a higher Sockets breaks the initialization of the sd Card since it is placed after the SD Card in the generated file.


in Program.generated.cs File

    private void InitializeModules()
        {   
			// Initialize GTM.Modules and event handlers here.		
			usbClient = new GTM.GHIElectronics.UsbClientDP(1);
		
			
		        sdCard = new GTM.GHIElectronics.SDCard(5);

			button = new GTM.GHIElectronics.Button(6); //this comes after the SD Card so it'll break the events of the SD Card upon boot
         
        }

//now if i do this it'll work...

    private void InitializeModules()
        {   
			// Initialize GTM.Modules and event handlers here.		
			usbClient = new GTM.GHIElectronics.UsbClientDP(1);
		
			
		
			button = new GTM.GHIElectronics.Button(6);
            
                        sdCard = new GTM.GHIElectronics.SDCard(5); //moved the SDCard last in Order now the events work.

        }

I will update the SDK and firmware to 4.1.8.0 and report back…

Jay


#4

Hello guys,

Updating to the latest SDK 4.1.8.0 and firmware took care of the problem… :-[

thank you and sorry about the wasted space…