LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SD card present?

Hello,

 

Is there a way to detect the drive letter assigned to an SD card when it is inserted into an internal SD card slot on a PC?  I used the List Folder function with an empty path wired into it which returns an array of all of the drive letters, but it returns all of the drive letters regardless if an SD card is inserted.

 

My original plan was as follows:

 

Run the list folder function and get the drive letters (Pre SD card insertion)

Prompt to insert SD card

Run the list folder function and get the drive letters (Post SD card insertion)

Compare the drive letter arrays to see what the new drive letter assigned to the SD card was.

 

The problem is that I get the same two arrays from the pre and post operations.  It's like the function sees the Multi-card slot hardware connected to the PC regardless if a SD card in connected or not. 

 

0 Kudos
Message 1 of 6
(3,285 Views)

Bump...

0 Kudos
Message 2 of 6
(3,267 Views)

Hi,

 

ever thought about tools like USBDLM?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 6
(3,261 Views)

AMac,

 

If your SD card slot is anything like the ones I use on occasion, it is going to be present in the drives whether or not there is a card physically in the slot. If you know the letter that the SD card slot is assigned, you could potentially look at what files are in the drive, and if no files are there, you can assume that either the slot is empty or the card is empty in the slot.

 

As for determining which slot is the SD card slot, I am not sure there will be a way to do that (depending on the type of SD card reader, Windows may not even know whether it is an SD card reader), but you could concievably have a unique file name on the SD card which you go through each possible drive, and check for the existance of that file. When you find that file, you know you have found the SD card slot, you can save it to a configuration file, and then from then on, you just check that drive.

David M.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 6
(3,240 Views)

@DmcG wrote:

AMac,

 

If your SD card slot is anything like the ones I use on occasion, it is going to be present in the drives whether or not there is a card physically in the slot. If you know the letter that the SD card slot is assigned, you could potentially look at what files are in the drive, and if no files are there, you can assume that either the slot is empty or the card is empty in the slot.

 

As for determining which slot is the SD card slot, I am not sure there will be a way to do that (depending on the type of SD card reader, Windows may not even know whether it is an SD card reader), but you could concievably have a unique file name on the SD card which you go through each possible drive, and check for the existance of that file. When you find that file, you know you have found the SD card slot, you can save it to a configuration file, and then from then on, you just check that drive.


 

Yes, the problem is that the drive letters are present when the card reader hardware is connected regardless of a media card being inserted.  This application will be deployed on multiple PC's with different media reader hardware configurations so I need to check all of the drives until I find the SD card drive letter.  I think that your recommendation to attempt to read a unique file to the SD card is the way to go since there doesn't seem to be a way to monitor available drives.

 

Windows 7 shows all of the drives in the explorer view, but they are disabled until a media card is inserted.  I was thinking that I could easily duplicate this functionality in LV, but it doesn't seem possible.  Maybe with a windows dll it could be done and if I have the time, I'll look into this approach.

 

0 Kudos
Message 5 of 6
(3,234 Views)

Hi AMac,

 

when you don't like USBDLM you could search a little bit more either here in NI forum or over at MSDN: there are functions which will provide you with drive properties like drive name and hardware type. So you could check each drive letter for it's type and name to find SD cards...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 6
(3,231 Views)