Results 1 to 7 of 7
I need to detect USB Mass storage device being plugged into a Linux system. How do i achieve this progamatically ? The requirement is to continously check if the USB ...
- 05-16-2007 #1Just Joined!
- Join Date
- May 2007
- Posts
- 1
Detecting USB devices in Linux
I need to detect USB Mass storage device being plugged into a Linux system. How do i achieve this progamatically ? The requirement is to continously check if the USB device has been inserted and read from the device if it is present else to read from local disk. Please let me know if anyone has pointers on the same.
Thanks in Advance
- 05-17-2007 #2
if your distro has udev support, rather than devfs, then you can use udev to do things like this. I used to have udev setup so that when i plug in my digital camera, it would see it's the camera, mount the camera to the file system, copy the pictures to a temporary storage somewhere, and then unmount the camera.
I haven't got this configuration any more since i reinstalled, but that may be an option for you to look into."I am not an alcoholic, alcoholics go to meetings"
Registered Linux user = #372327
- 05-17-2007 #3Just Joined!
- Join Date
- Aug 2006
- Location
- india
- Posts
- 57
U can use :dmesg
after which u can mount it
If ur luking for a C code go to drivers source
find usb/storage in 2.6
luk in usb_device structure abt "probe& disconnect"
some skeletonusb driver is also present in source,I hope u can modify & reuse it
- 06-21-2007 #4
- 06-22-2007 #5
- 07-01-2007 #6
Thanks, sdousley.
So, do you have any updates or info?
Do you have any idea how you did it in the first place?
I'm sure learning how all of this works would help me.
I'm not too familiar with how Linux treats the HAL and all of that.
To say the least, I need to learn more about how linux deals with the most common hardware.
I haven't the slightest clue as to how udev is handled. I tried looking it up a week ago, but I didn't learn much. Nor did I get far.
As a possibly relevant sidenote of mine:
But to be more relevant....I do think there could be some interesting implementations.
For instance, a person could intermittently control the camera to upload pictures after each snapshot with a couple key commands or perhaps some timed delays. This would allow the user to view the recently snapped image.
I've been trying to understand more about how digital cameras work, and it seems the USB port throws out a certain amount of current (50 mA?). Now, my knowlege of electronics is super, god awful rusty, but I'm thinking the USB device counters the current, thus activating the device's software to load into the computer via USB. This then makes a digital camera notice that it is currently hooked upto the computer.
If there was a way to disable this, a person could create a shortcut key to activate it when a person wants view the image he or she recently captured.
I tried disabling the USB devices and power output on my Windows 2000 pro computer, but it didn't do any good. I don't really know if the current from the USB port was turned off, though. Regardless, after I disabled the all of the USB options in device manager, the camera still believed it was hooked up to the computer. Therefore, this makes me believe that some current is being applied and counterapplied/resisted to the USB port; thus allowing the camera to think it's hooked up to the computer. If the camera does not think it is hooked to the computer, then a person could keep a USB cable attached to the camera's and computer's USB ports. However, I couldn't find a way to make the digicam think that it was _not_ hooked up to the computer.
Lot's of possibilities with manipulating this digital camera system in Linux, but I don't know enough about the hardware and software connections. I don't really know where to start when it comes to Linux. I'll have to find some books or something...
Would this have to do with calling external programs? :
1) redhat.com | Red Hat Magazine - Configuring Devices with udev
2) Writing udev rules
So, basically a person codes udev to recognize a certain device. Once it recognizes that devices, it calls a script. From there, the script can do whatever the user desires. Is that right?
So, a person needs to create udev rules and a retreival script for post-recognition, right?
1. Assign the device a name
2. Assign a recognition system
3. (Create a script / Launch a program) to be run after post-recognition
Looks logical to me.
If I remember correctly, digicams are prescribed as scsi devices, right?
- 07-02-2007 #7
I think all you will need to know can be found Here.
As for one of your sidenotes about capturing the devices pictures, i think that would rely on the camera as well as the script. For example, i CANNOT have my camera on "usb mode" where the computer can see it AND in capture mode where the camera can capture pictures. The only way i can switch between the 2 is to press a physical button on the dock for the camera, so this may need a little more thought. For something like that you'd b better off getting a webcam of some sort."I am not an alcoholic, alcoholics go to meetings"
Registered Linux user = #372327


Reply With Quote
