Skip to contentSkip to conversation

Hotplugging USB Compact flash reader

DISCUSSION Ajay 2 participants 3 messages Aug 9, 2002 – Aug 10, 2002

lore
Share & tools
lore

Ajay

author
#0 lore raw

HI,
I am a first timer in this groups.
I am trying to develop something that can recognize when a USB Flash card reader is plugged in, when a media is plugged into the reader, and when either of them are removed. Something like plug and play - just plug in and an icon appears on the desktop which takes you to the diectory. I guess hotplugging should have the answer.
I read as much as I could but I can't figure out where /sbin/hotplug and usb.agent fit in. How do I trap the hotplug notification? Do I have to "register"? How do I do that?
Thanks and regards,
Ajay

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#1 lore raw

I figured out enough of usb.agent to be able to trace it to a point where I found that the handbook and the userbook do not have a match for the VID-PID for the reader that I'm using (it's an SCM ORCA cf-ms-sm-sd reader). However I found that it loads (binds?) the correct drivers. So in the "add" event I simply added "mount /dev/sda /mnt/cf" and in the "remove" event I unmounted it. All this is in usb.agent.

In Gnome this works fine - an icon comes to the desktop without me having to do anything else. In KDE, there is no icon, but the device is mounted.

My question is:
1. Is it correct to modify usb.agent itself? Should I rather include the VID-PID and other details in the handbook/userbook?

2. What is the "match-flag"?? AFAI can see it seems to be a "mask flag" - something to be 'anded' with something else. What is the principle behind it?

3. This is premature, but could someone give me a hint as to which desktop agent I should be talking to?

Thanks and regards,
Ajay.
--- David Brownell <[email protected]> wrote: >

Quoted 74 lines · Ajay
Quoted 3 lines

HI,
I am a first timer in this groups.
I am trying to develop something that can

recognize

Quoted 2 lines

when a USB Flash card reader is plugged in, when a media is plugged into the reader, and when either

of

Quoted 1 line

them are removed. Something like plug and play -

just

Quoted 1 line

plug in and an icon appears on the desktop which

takes

Quoted 1 line

you to the diectory. I guess hotplugging should

have

Quoted 1 line

the answer.

You're asking about a missing piece, or maybe a
couple.

- "disk level" hotplug events, reporting new storage so that it can be mounted. in 2.5 it seems like at least the "scsi hotplug" may really happen,
which
should solve your USB cardreader issue.

- hotplug events talking to X11 desktops

UNIX desktops traditionally "knew" that only a few devices
might ever get new media, and polled things like diskette
and cdrom devices from some desktop monitoring program.
(Maybe not the same one polling for filesystem changes.)

Of Linux today, such devices can connect
dynamically, so
any "poll only these devices" architecture just
loses.

One of the KDE or GNOME object model hooks ought to do
nicely to let some hotplug agent talk to some service
running inside the desktop, reusing infrastructure that'd
otherwise need to be reinvented for a "raw X11" solution.

Quoted 1 line

I read as much as I could but I can't figure out

where

Quoted 1 line

/sbin/hotplug and usb.agent fit in. How do I trap

the

Quoted 1 line

hotplug notification? Do I have to "register"? How

do

Quoted 1 line

I do that?

Considering that you'd need to design some of the hotplug
events needed to address this problem, you'll need to
understand enough to create those answers yourself ... or
wait for someone else to address them! :)

The core observation will be that the hotplug agent for
some TBD "storage hotplug event" would need to invoke some
program that's permitted to talk to the relevant desktop
service, which would pop up your desktop icon.

Quoted 5 lines

- Dave

-------------------------------------------------------

Quoted 8 lines

This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Linux-hotplug-devel mailing list
http://linux-hotplug.sourceforge.net
[email protected]

https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

=="The worst thing one can do is not to try, to be aware of what one wants and not give in to it, to spend years in silent hurt wondering if something could have materialized -- and never knowing."
- David Viscott

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#2 lore raw
In reply to Ajay
Quoted 4 lines

1. Is it correct to modify usb.agent itself? Should I rather include the VID-PID and other details in the handbook/userbook?

Don't modify usb.agent, no ... /etc/hotplug/usb/$DRIVERNAME is where you put per-driver setup/config tweaks.

From what you said, you're assuming only one reader (or
SCSI-ish device) will ever be connected ... you're choosing a single device name and mount point. That's error prone; the reason is that you're using the wrong level of hotplug event. As I said earlier, to solve this safely you need higher level hotplug events: "here's a disk" (/dev/sdc or whatever).

Quoted 3 lines

2. What is the "match-flag"?? AFAI can see it seems to be a "mask flag" - something to be 'anded' with something else. What is the principle behind it?

See <linux/usb.h> for "struct usb_device_id" support.

Quoted 2 lines

3. This is premature, but could someone give me a hint as to which desktop agent I should be talking to?

To my knowledge, there is no such desktop agent yet. That's why I suggested you be prepared to write one.

- Dave

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel