LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect write protected SD card

Solved!
Go to solution

Hello all

 

I couldn't find the answer to my question, so I have started a new thread.

 

Problem: I would like for Labview (or TestStand directly) to programatically detect if an SD (secure digital) card has the "write protection" slider switch active.

Is this possible somehow?

 

PS: I was also not able to find this information anywhere in Windows 7 as well. I'm using LV 2011 SP1.

PPS: At the moment I try to create a file on the SD card, and detect the write error, which tells me if the card is protected or not. But I would like a more elegant solution.

 

0 Kudos
Message 1 of 8
(4,265 Views)

You could try to use the GetVolumeInformation function provided by Win32API.

It should return you a flag stating the device is read only....

 

 

http://msdn.microsoft.com/en-us/library/windows/desktop/aa364993%28v=vs.85%29.aspx

http://support.microsoft.com/kb/139547

 

 

Regards,

Marco

0 Kudos
Message 2 of 8
(4,254 Views)

Unless you want to dive deeply into Windows device drivers itself and intercept some messages on that API level I'm afaid your way of detecting write protection is the only feasable one.

 

The link by Marco might give you a feasable solution, the problem is that those flags are not always correct for all possible mediums including network shares.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 8
(4,251 Views)

This is a hardware 'problem'.

 

The write protect function is set by the reader itself by physically engaging a switch depending on the write protect slider position. You can usually override this behaviour from the registry, but that's besides the point.

 

Your approach is the only one that I've ever seen work without gaining access to that switch via IO. You can't use Get Permissions because Windows sees the permissions the same regardless of the slider position.

 

As for elegance, it sounds pretty elegant to me already 🙂

 

Edit - you learn something new every day.

 

Write protect engaged: 000010000000000000000110

Write protect disengaged: 000000000000000000000110

 

I will hang my head in shame and rewrite some VIs now!

---
CLA
0 Kudos
Message 4 of 8
(4,246 Views)
Solution
Accepted by topic author teknik_kim

Wow, it's already there for Labview: http://zone.ni.com/devzone/cda/epd/p/id/2048

 

All you have to do (hopefully) is to parse that "flags" value!!

 

Marco

 

Message 5 of 8
(4,245 Views)

Hi guys

 

Thanks for the suggestions.

 

I got what I needed, both a simple and a more advanced solution 🙂

 

-Kim

0 Kudos
Message 6 of 8
(4,178 Views)

Hi Kim.

If you want you can mark the issue as solved and give kudos ;=)

 

Marco

 

0 Kudos
Message 7 of 8
(4,173 Views)

i had similar issue with my sd card i have followed steps in this post and it solved my issue of sd card write protected. i hope you will also get your solution on write protected issue.

0 Kudos
Message 8 of 8
(3,751 Views)