LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-15-2010, 08:47 AM   #1
J.Richardus
LQ Newbie
 
Registered: Oct 2010
Posts: 1

Rep: Reputation: 0
Recognizing USB insertion/removal in Python


Hi all,

How can I understand if a USB inserted or removed. I don't know where to start so any help would be appreciated.

Someone said I need to study HAL. Is it true? If so I need some links, source code etc. do you know any?

Thanks in advance...
 
Old 10-15-2010, 11:08 AM   #2
PhantasyConcepts
LQ Newbie
 
Registered: May 2009
Posts: 19

Rep: Reputation: 3
Talking Changes in hardware configuration are hardware based.

First of all, you cannot truly detect any hardware configuration through your scripting. You can probe for it, but the operating system kernel detects hardware changes like that. I would suggest probing /dev/usb for changes (or whatever your distro calls the usb device). Another thing to try is to execute an lsusb -v command, at the beginning and just pipe the output to grep for your search string. Python can execute system commands.

If you are, however, writing a device driver, write it in C first of all, and then you would want to take a look at the HAL API and the kernel source code.
 
1 members found this post helpful.
  


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
How can I run a script at usb insertion? ahmad2080 Programming 3 09-21-2010 08:42 PM
USB insertion notification paldebojyoti Linux - Distributions 3 08-21-2009 05:32 AM
How do i detect insertion/removal of devices? Pramoda.M.A Linux - Software 4 07-13-2009 05:20 AM
How to detect insertion/removal of flash card in usb reader? logularjason Linux - Hardware 9 06-24-2006 03:11 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:26 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