LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-10-2009, 04:30 AM   #1
Pramoda.M.A
LQ Newbie
 
Registered: Mar 2009
Location: Bangalore
Posts: 11

Rep: Reputation: 0
Cool How do i detect insertion/removal of devices?


Hi All,

How do i detect insertion/removal of external devices like SD card, USB devices etc., in my program, which should be running in thread. If single API is available, it will be too good. Otherwise, please suggest me the how to achieve that.

Regards,
Pramod`
 
Old 07-10-2009, 05:03 AM   #2
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 988
Blog Entries: 4

Rep: Reputation: 254Reputation: 254Reputation: 254
Greetingz!

For most USB, FireWire, and Hot-Pluggable SCSI devices, you should catch an entry in your syslog. On a Linux system, you want to watch the /var/log/messages file. However, check your /etc/syslog.conf or /etc/syslog-ng.conf file to be sure.

As for detecting SD card insertion and removal. If it's a built-in SD card reader, the syslog method above should apply. However, if it's an external USB card reader, there's a good chance that nothing will get reported. (I've had several multi-format card readers fail to detect when a new card was inserted, typically I wind up having to unplug/replug the reader.)

Click the thumbs-up if this helps!
 
Old 07-10-2009, 08:13 AM   #3
nanoo
LQ Newbie
 
Registered: Jul 2009
Posts: 19

Rep: Reputation: 1
use dbus+hald.
 
Old 07-13-2009, 02:40 AM   #4
Pramoda.M.A
LQ Newbie
 
Registered: Mar 2009
Location: Bangalore
Posts: 11

Original Poster
Rep: Reputation: 0
possible to help me to code?

Hi,
is it possible to help me foe implementation in C programming? Or how should i prooced? Could u please give me the alogrithm?
 
Old 07-13-2009, 05:20 AM   #5
nanoo
LQ Newbie
 
Registered: Jul 2009
Posts: 19

Rep: Reputation: 1
dbus is messaging system. Application "connect" to this bus an listen. When some event in some app happend dbus delivers this event to another subscribed on this event app.
hald generates some event when kernel reports when some new device was found. You need to make your program dbus-client capable and listen for hald events. I think you can find some documentation on the site. There are examples should be somewhere too.
http://dbus.freedesktop.org/doc/dbus-tutorial.html
http://docs.sun.com/app/docs/doc/819-2252/hal-5?a=view
http://allinweb.blogspot.com/2009/04...act-layer.html
http://madison-project.wdfiles.com/l...l_Tutorial.pdf
Good luck!
If you finish please make some post. What you get, problems and so on. Im going to use hal in future maybe I event will have the same task as you do.
ps. Of course you can watch on syslog event directly. I mean solution was proposed in post above. If you need simple solution do that way. But I would do it with hald.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot Detect Usb Devices garbo365 Linux - Newbie 17 09-21-2007 11:55 AM
How to detect insertion/removal of flash card in usb reader? logularjason Linux - Hardware 9 06-24-2006 03:11 AM
Xorg can't detect any devices worldgnat Linux - Software 2 06-20-2006 05:06 PM
Can't detect usb devices?? CM019 Debian 5 06-09-2005 01:43 PM
Bootup freezes after removal of USB devices hontoo Linux - Hardware 0 12-04-2004 12:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration