From the examples I have the following code. It’s an event handler that gets triggered when I insert an USB device. It works as expected with the thumb drive but not with the SD card reader. It doesn’t matter if I insert the card reader with or without a card. I tried with PersistentStorage(device) and PersistentStorage(device, 0) and also with 1,2,3 as second argument. (Windows detect the card reader as two drives).
System.Exception is very generic. Can I enable more debug features or trace into the GHI libraries to see on what it fails?
Or can I start from the USBH_RawDevice class and read/write some messages to the device to see what is going on? Are there any source snippets that I could use for that?
It’s the only one I have so I wanted to test with it. It works fine on the desktop system so it would be better if the issue can get resolved otherwise you end up creating a list of what is and isn’t supported rather than coding against specs.
I ordered the single slot SD Card reader I am planning to use in the final product. They should arrive next week. I wasn’t planning on ordering them until I was done testing with the stuff I already had to keep the costs low in case the project falls through because of things like this.
If windows detects it as two drives, this may be that your SD card is formatted with two partitions. Try with an SDCard freshly formatted as FAT32. If the problem persists, this is due to the card reader that instantiates mounting points even if there’s no real filesystem (i.e. SD card) connected.
What about your SDCard reader without SD inserted on windows?
The card reader without card shows up as two hidden drives in Windows (just tested). There are three slots on this device:
[ulist]T-Flash/MicroSD
SD/MMC
MS[/ulist]
I only have a SD card to test with, but I would think two of those slots share a logical drive, and then the other slot is a drive of its own. Maybe because of the cards being diff technology or something. The 60-in-1 or something card reader that is build in the desktop system shows up as a number of drives as well (hidden drives when empty).
I reformatted the card for FAT32, still the same logging.
I commented the lines:
// ps = new PersistentStorage(device, 0);
// ps.MountFileSystem();
And it gave this logging:
Device connected…
ID: 1073773092, Interface: 0, Type: 6
USB Mass Storage detected…
So it sees it as one USB Mass Storage… it does that with or without the card inserted.
Is this what you mean with mounting points? Sounds fair that it would raise an exception when the event is raised and there isn’t a card inside, but it should just work when the card is present at the moment of the event.
I’m not sure what that second argument (byte) is, that’s the logical drive? So when I get two drives in windows (J & K) and J is the SD card than that second argument would be 0 for the SD card?
I received the SD card readers (single slot) that I’m planning on using and finally gotten around doing some initial tests and the readers are detected and I can read file and directory structure, and the content of a file from them. Haven’t tested writing to them yet.
A weird thing is that they are seen as a thumb drive, not as removable storage media. Is this normal? When I insert the card reader with card, events fire, and I can start using it. When I insert the card reader without a card, the same events fire, and I have to catch exceptions.
So there doesn’t seem to be a way to determine if a storage card is actually present in the card reader besides just trying to access it and catching the exception. To get notified about a card insert I would have to implement a polling. This seems like a waste of CPU to be honest.
I’m a missing something, or is this due to the SD card reader itself?
I’ve seen many hardware implementations make choices that seem strange, but it comes down to what reference design the “designer” used when they built their module in Shenzen or wherever. Obviously some chips only present a storage device not a card reader, even though they’re physically a card reader; in a PC that isn’t usually a big deal, but it’s something you have to cater for yourself at this level, as you’ve found.
Thanks for the replies. I will design the software accordingly. Plus side to this is that I can go with the cheap card readers I ordered (there’s no need for a high end / more expensive reader if it doesn’t offer more functionality)