LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I eject a USB based romavable disk (thumb drive) using LabView

Hi,
 
In one of my test programs, I need to "eject" a removable disk (USB thumb drive) from the system. Can anyone help me on this?
A "remove device" cannot be performed as the USB disk will behave differently when it is "removed" rather than "ejected". I am not using NI-VISA for the USB device.
 
I am using LabView 7.0 on WinXP/2000.
 
Thanks in advance!
 
Deepu.
 
0 Kudos
Message 1 of 10
(4,893 Views)

My experience is that you can't eject a thumb drive because LV will continue to hold a reference to it open until it quits itself. What I do is when I'm done with the drive is wait a while and then I pull the drive out. Yes, Windows will complain and warn you about possible data loss, but short of shutting down LV I have found no way of getting it to let go of the drive.

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 10
(4,874 Views)
Is your problem the LV implementation or the windows implementation?
 
If it's LV - you can try by starting here for some links about working with DLLs or you can tell us what you know and where the problem is.
 
If it's windows - I think you should go to the MSDN first.
 

___________________
Try to take over the world!
Message 3 of 10
(4,869 Views)
I think I need to make my problem more clear.
 
I have this device equipped with a USB port and which supports a lot of self tests.
During one of its tests, it appears as a removable device like a thumb drive. So the PC recognise it as a removable drive and allows me to copy files into it. To complete the test, I need to eject the 'drive'. During my offline testing, I have tried clicking the taskbar icon and removing it. But, this will not complete the test. If I open the explorer window and right click on the device name and 'eject' it, it completes the test. I believe this is due to the different messages sent by windows to the device's USB port.
 
So what I need to know is how to do the 'eject ' using LabView.
 
Thanks to all the LabView experts!
 
0 Kudos
Message 4 of 10
(4,846 Views)
"I see...", said the blind man...
 
It looks like you need the Windows call that does the eject. I would follow tst's advice and start on MSDN and do a search on "eject disk" or the like.
 
Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 10
(4,842 Views)
It seems like that link has become out of date. I should have checked it then. Here's a replacement.

___________________
Try to take over the world!
0 Kudos
Message 6 of 10
(4,824 Views)

There's some weird behaviour with USB flash drive and LabVIEW.  As you all have noted above, accessing a file directly from the USB driver using LabVIEW File IO functions appears to "hold" the drive -- we cannot "Safely remove the drive" using the tray icon (until LabVIEW is shutdown; even though all file references are closed). 

However, a strange thing I noticed is that if I then access a local file (as on my C: drive), I can then safely remove the USB stick.  It appears that reading the local file forced LabVIEW to somehow "release" the USB drive!

Anybody know what could be happening here?  Any way of "releasing" the USB drive programmatically?

Thank you in advance!

-Khalid

0 Kudos
Message 7 of 10
(4,755 Views)
Dear Tst:
             If you are not a expert of Labview and API, You should be only Standby. What you say is not any helpful to this topic, i have seen your the same answer for the same question almost half a year ago. Have you tried ? Can you give a solution ? You cannot , you just know those so called suggestion?
0 Kudos
Message 8 of 10
(4,745 Views)

I am not an expert on interfacing LV with the windows API, nor have I tried to disconnect a USB device programmatically, so the answer I gave was the only one I have. If I had a better answer, I would have given it.

The reason I gave this answer was because it's not clear where the problem was - you should note the difference between what Khalid describes and what Deepu says in post 4 - it seems that the original problem was finding a way to make to make the windows call, in which case my advice from 2 months ago was perfectly suitable as an answer (as acknowledged by Mike).

As for my previous answer, you may have seen it, but apparently Deepu did not. If people would actually search for an answer before posting, the activity in this board would drop considerably, but since most people don't search, we end up giving the same replies over and over.

And in case it wasn't clear - don't tell me what not to do, especially when it seems you're wrong. As long as a person isn't actively polluting the forum (let's say by asking the same question in multiple threads), there is no need to make remarks. Just ignore the things that bother you.


___________________
Try to take over the world!
Message 9 of 10
(4,740 Views)