Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
170 user(s) are online (149 user(s) are browsing Forums)

Members: 3
Guests: 167

Petrol, jabirulo, Mr_byte, more...

Support us!

Headlines

 
  Register To Post  

detect usb stick
Home away from home
Home away from home


See User information
I'm having a problem i need help with. I'm trying to figure out a way to detect when user inserts a usb stick. For this i'm using the following code:

file_lock Lock("usb0:",SHARED_LOCK); 
if(
file_lock != (BPTR)NULL)
printf("found usb\n"); 
UnLock(file_lock);  

else     
{     
printf("no usb\n"); 
UnLock(file_lock);
}


This works when the usb stick is allready inserted upon start of the program. But when i insert it when the program has been running for some time. It always gives me no usb whether the usb is inserted or not. Anyone has a clue why???

X5000
Go to top
Re: detect usb stick
Just popping in
Just popping in


See User information

I don't think it's necessary (or wise) to UnLock a lock that you never Lock'ed successfully.

I was going to say that you cannot get a shared lock if there is already an exclusive lock.. the docs says that only files will get exclusive locks though. :)



Go to top
Re: detect usb stick
Home away from home
Home away from home


See User information
I've changed the code.
I found autorun.inf on my stick. Is this file present on all new sticks?

X5000
Go to top
Re: detect usb stick
Home away from home
Home away from home


See User information
NO

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: detect usb stick
Home away from home
Home away from home


See User information
Any other solutions for detecting usb stick?

X5000
Go to top
Re: detect usb stick
Home away from home
Home away from home


See User information
http://www.os4depot.net/index.php?fun ... ty/filetool/freespace.lha

I think it has some source code you might modify, or look at to understand, if you like to.

Or else you might do a hock on Exec AddDevice and RemDevice its bit more dirty but at least you not dont need to pool for device is interserted or not, but its more risky as it might crash your OS, if do it wrong.


Edited by LiveForIt on 2013/4/20 14:43:43
Edited by LiveForIt on 2013/4/20 17:34:30
(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: detect usb stick
Quite a regular
Quite a regular


See User information
You might ask Fredrik Wikstrom/salass who implemented an "Autorun" feature already. See OS4Depot.

X1000|II/G4|440ep|2000/060|2000/040|1000
Go to top
Re: detect usb stick
Just can't stay away
Just can't stay away


See User information
Why do you want to detect specifically that an USB stick is inserted? That's not very flexible. (And judging by your code sample, it would even have to be the first USB disk inserted, since you look specifically for USB0:)

Are you asking the user to make a particular file available, or is your program going to scan a volume, looking for particular types of files or something?

In any case, maybe you should let the user direct the program to the file or volume you need by means of a file requester.

That concept of having the system do something automagically when inserting a medium is contradicting the usual AmigaOS goal of giving the user control.

Just some thoughts for consideration.

Best regards,

Niels

Go to top
Re: detect usb stick
Home away from home
Home away from home


See User information
Its a small project im fiddling with. And the only user will be me so the approach is fine. It's for detecting and scanning the usb stick for certain files. and will only be 1 usb available anyway.

X5000
Go to top
Re: detect usb stick
Just popping in
Just popping in


See User information
How about intuition events IDCMP_DISKINSERTED and IDCMP_DISKREMOVED ?

http://gega.homelinux.net/AmigaDevDocs/lib_9.html

You can scan your disk if you get at least a IDCMP_DISKINSERTED event...

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project