Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.)
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.