SD Card (v1.4) compatibility with FEZ Raptor

Hi all,

It’s been a while since I’ve really dabbled in the gadgeteer world so please excuse my failing memory.

Firstly I just wanted to double check that my SD Card module v1.4 is compatible with the FEZ Raptor. (It came with the spider kit)

I’ve upgraded everything to 4.3SDK (TinyLoader, TinyCLR)

I’m also running on:

.NET Micro Framework SDK 4.3 (SDK-R2-Beta)
Latest Gadgeteer core
NETMF and Gadgeteer Package 2014 R5

Using the following code it seems like I successfully mount an SD card:

        Private Sub InitialiseSDStorage()
            If sdCard.IsCardInserted = False Then
                Debug.Print("Waiting for SD card to be mounted")
                While sdCard.IsCardInserted = False
                    Thread.Sleep(500)
                End While
            End If

            If sdCard.IsCardMounted = False Then
                Debug.Print("Mounting SD Card")
                Try
                    sdCard.Mount()
                Catch ex As Exception
                    FatalError(ex.Message, "InitialiseSDStorage")
                End Try

                Thread.Sleep(1000)
            End If
            If sdCard.IsCardMounted = False Then
                FatalError("Cannot Mount SD Card", "InitialiseSDStorage")
            End If
            Debug.Print("SD Card Mounted")

            storageDev = sdCard.StorageDevice

            ' Setup routines to cat the ejecting of sd card
            AddHandler sdCard.Unmounted, AddressOf sdCard_SDCardUnmounted
            AddHandler sdCard.Mounted, AddressOf sdCard_SDCardMounted
        End Sub

I then try to load a bitmap off of the card using the following code (The path is “\project\images\logo_lrg.bmp”):

        Private Function LoadBitmap(fname As String) As Bitmap
            Dim result As Bitmap
            Try
                result = storageDev.LoadBitmap(fname, Bitmap.BitmapImageType.Bmp)
            Catch ex As Exception
                FatalError(ex.Message, "LoadBitmap(" & fname & ")")
            End Try

            Debug.Print("Image size = " & result.Width.ToString & " x " & result.Height.ToString)
            Return result
        End Function

I get the following exception:


    #### Exception System.IO.IOException - CLR_E_INVALID_DRIVER (1) ####
    #### Message: 
    #### Microsoft.SPOT.IO.NativeIO::GetAttributes [IP: 0000] ####
    #### System.IO.FileStream::.ctor [IP: 005c] ####
    #### System.IO.File::ReadAllBytes [IP: 0008] ####
    #### Gadgeteer.StorageDevice::LoadBitmap [IP: 000b] ####
    #### ProjectDemo.HothouseDemo.Program::LoadBitmap [IP: 0009] ####
    #### ProjectDemo.HothouseDemo.Program::LoadImage [IP: 000d] ####
    #### ProjectDemo.HothouseDemo.Program::ProgramStarted [IP: 0012] ####
A first chance exception of type 'System.IO.IOException' occurred in Microsoft.SPOT.IO.dll
A first chance exception of type 'System.IO.IOException' occurred in System.IO.dll

Any help is appreciated.

Cheers,

Jas

I’ve been fiddling and tweaking the code but I finally found the cause. It was a bit of a misleading error message but the error was caused by:



Changing it to:


```vb]Dim path As String = "project\images\" & imageName[/code


Fixes the issue.

A single character!

:-[

Anyway back to the fun stuff :)

Jas

Your problem was that any path starting with ‘’ is a root path, where as without a backslash at the beginning it’s an relative path to the current directory.
If you want to access the SD card with a routed path, start with '\SD…'
I thing the StorrageDevice also has an property giving you the root path of the device. That is usefull when multiple USB sticks are connected.

Thanks.
I grabbed code from a previous project I had on a FEZ Spider where this used to work. I’m slowly getting back into things. Going to try and create the T35 display device (Mentioned in another thread) and then try and get Glide working.

Then it’s plugging in the new Ethernet module I’ve just ordered and connecting to my companies REST API we have on a demo server in the cloud.

Lots of new things to learn.