The MP3car.com Store  

Welcome to the MP3Car.com forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. Registering will also remove advertisements. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   MP3Car.com > Mp3Car Technical > Linux

Reply
 
Thread Tools Search this Thread Display Modes
Old 09-23-2005, 01:54 PM   #1
Low Bitrate
 
Join Date: Sep 2005
Posts: 80
My Photos: (0)
detect CD insertion

Hi everyone,

Anybody know how to detect when a CD has been inserted? Or, even better, how to detect when a CD is in the process of being inserted (in a slot-load drive)? I assume the process is different whether it's a USB or IDE drive. I haven't decided which one I want to use yet. Maybe the ability to detect media insertion might sway me
gentoocar is offline   Reply With Quote
Sponsored Links
Old 09-23-2005, 05:26 PM   #2
Variable Bitrate
 
Join Date: Mar 2002
Posts: 395
My Photos: (0)
You could look at the source code of an automounter, and see how it detects CD insertion, then write your own program to do what you need, or just monitor /dev/cdrom (maybe called something else if you're using udev) for when the automounter mounts it. I don't think IDE nor USB send tray-open/close or disc insertion signals.
tom61 is offline   Reply With Quote
Old 09-23-2005, 08:03 PM   #3
Newbie
 
Join Date: Jun 2003
Vehicle: 1994 Acura Integra LS
Posts: 35
My Photos: (0)
i use ivman, and it works great. its currently hardmasked in gentoo's portage system, but the older versions work great. i haven't upgraded yet to the newer version that uses pmount since gentoo also has that hard masked. of course you can compile from source.

i've set it up to:
1. detect audio cd, auto play via mplayer by mounting a cdfs partition and simultaneously copy and compress into ogg.
2. detect dvd, auto play via mplayer
3. detect data cd, auto mount under media

i highly recommend it. also, your assumption of it being different for usb/ide is gradually becoming incorrect. with udev, dbus, and hal, all hardware is being autodetected, auto fstabed, auto dev creation, etc. ivman even works with usb sticks, and pretty much any removable media that can be attached and detected by dbus/hal.

you can also use gnome-volume-manager for the same purpose supposedly. i have not used it, since i'm not using X at all. ivman is console/daemon based.

finally, ide/usb/firewire drives are all at the root the same i believe: ide drives with a usb/firewire bridge. and ide does have the tray open/close, tray lock, disc insertion detect, cd type detect etc. available to userspace via hal.

Last edited by ruzzmon; 09-23-2005 at 08:06 PM. Reason: typo
ruzzmon is offline   Reply With Quote
Old 09-26-2005, 09:09 AM   #4
FLAC
 
TheLlama's Avatar
 
Join Date: Jul 2004
Location: All over the world
Vehicle: 2001 Paper Airplane Standard Edition
Posts: 984
My Photos: (0)
second on ivman
TheLlama is offline   Reply With Quote
Old 09-26-2005, 11:55 AM   #5
pkg
Low Bitrate
 
pkg's Avatar
 
Join Date: Apr 2005
Location: Arizona
Vehicle: 2005 Scion tC
Posts: 96
My Photos: (0)
Hey, new people. Welcome

I know that debian does an automount to /dev/cdrom but i always seem to break this and have never looked into how it works. Maybe someone here knows?
__________________
-pkg

Check out my tC: http://publicjestering.com/tc
Check out my site: http://publicjestering.com
pkg is offline   Reply With Quote
Old 09-26-2005, 01:42 PM   #6
Low Bitrate
 
Join Date: Sep 2005
Posts: 80
My Photos: (0)
Quote: Originally Posted by ruzzmon
i use ivman, and it works great. its currently hardmasked in gentoo's portage system, but the older versions work great. i haven't upgraded yet to the newer version that uses pmount since gentoo also has that hard masked. of course you can compile from source.

Thanks! That looks really nice, I like that it can do different things based on the media type (CD audio vs CD data).

Quote: Originally Posted by ruzzmon
finally, ide/usb/firewire drives are all at the root the same i believe: ide drives with a usb/firewire bridge. and ide does have the tray open/close, tray lock, disc insertion detect, cd type detect etc. available to userspace via hal.

I installed HAL and ran it, then looked at all of the DBUS messages. I can see events happening when I plug in USB keychains. But when I insert a CD, (into my IDE drive) nothing happens. The CD drive is working, and I can mount the CD manually. Any ideas why HAL can't detect it?
gentoocar is offline   Reply With Quote
Old 09-26-2005, 07:04 PM   #7
Newbie
 
Join Date: Jun 2003
Vehicle: 1994 Acura Integra LS
Posts: 35
My Photos: (0)
Quote: Originally Posted by gentoocar
Thanks! That looks really nice, I like that it can do different things based on the media type (CD audio vs CD data).



I installed HAL and ran it, then looked at all of the DBUS messages. I can see events happening when I plug in USB keychains. But when I insert a CD, (into my IDE drive) nothing happens. The CD drive is working, and I can mount the CD manually. Any ideas why HAL can't detect it?

hmm...i think thats a bit unusual. did you run lshal? if you have, make sure your cd drive is showing up. if it is, then insert a dvd (maybe a cd works too) and run lshal again, it should show a few keys change and the title of the dvd. at least thats how it works on mine.

but i guess you say that dbus isn't sending messages...maybe i'm wrong and not all drives are the same??? hal depends on dbus, so i could be way off.

also, i'm not really new, i just haven't really posted
ruzzmon is offline   Reply With Quote
Old 09-28-2005, 05:42 PM   #8
Low Bitrate
 
Join Date: Sep 2005
Posts: 80
My Photos: (0)
Hi ruzzmon,

I just tried a few things - first, running hald in --verbose=yes mode. I get a ton of printouts scrolling past whenever I plug in or unplug anything. But it's completely silent when I put in a CD, open up the Gnome CD player app, and play it.

Then I ran lshal. It detected 39 (!) devices. But it looks like it does have some information about my CD drive, but just lists it as "IDE device (master)" - doesn't mention anything about it being a CD drive.

Here's what I think is the relevant section from the lshal output. Do you get something significantly different?

Code:
udi = '/org/freedesktop/Hal/devices/ide_1_0' info.udi = '/org/freedesktop/Hal/devices/ide_1_0' (string) info.product = 'IDE device (master)' (string) ide.channel = 0 (0x0) (int) ide.host = 1 (0x1) (int) info.parent = '/org/freedesktop/Hal/devices/ide_host_1' (string) ide.linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:1f.1/ide1/1.0' (string) linux.sysfs_path_device = '/sys/devices/pci0000:00/0000:00:1f.1/ide1/1.0' (string) linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:1f.1/ide1/1.0' (string) info.bus = 'ide' (string)

gentoocar is offline   Reply With Quote
Old 09-29-2005, 12:42 AM   #9
Newbie
 
Join Date: Jun 2003
Vehicle: 1994 Acura Integra LS
Posts: 35
My Photos: (0)
This is what my cd drive looks like in hal, w/o a cd in it. I'll try to get you an output of what lshal looks like w/a DVD in it. keep in mind that i have a firewire bridge going to a pcmcia firewire card, so thats where the scsi and ieee1394 stuff comes from

Code:
udi = '/org/freedesktop/Hal/devices/block_11_0' storage.policy.desired_mount_point = 'cdrom' (string) storage.policy.mount_filesystem = 'auto' (string) storage.policy.should_mount = true (bool) info.udi = '/org/freedesktop/Hal/devices/block_11_0' (string) storage.requires_eject = true (bool) storage.hotpluggable = true (bool) storage.cdrom.write_speed = 0 (0x0) (int) storage.cdrom.read_speed = 4224 (0x1080) (int) storage.cdrom.support_media_changed = true (bool) storage.cdrom.dvdplusrw = false (bool) storage.cdrom.dvdplusr = false (bool) storage.cdrom.dvdram = false (bool) storage.cdrom.dvdrw = false (bool) storage.cdrom.dvdr = false (bool) storage.cdrom.dvd = true (bool) storage.cdrom.cdrw = false (bool) storage.cdrom.cdr = false (bool) storage.removable = true (bool) info.product = 'DVD-ROM SR-8184' (string) info.vendor = 'MAT****A' (string) storage.drive_type = 'cdrom' (string) block.storage_device = '/org/freedesktop/Hal/devices/block_11_0' (string) storage.physical_device = '/org/freedesktop/Hal/devices/ieee1394_0' (string) storage.vendor = 'MAT****A' (string) storage.model = 'DVD-ROM SR-8184' (string) storage.automount_enabled_hint = true (bool) storage.no_partitions_hint = true (bool) storage.media_check_enabled = true (bool) storage.bus = 'ieee1394' (string) block.minor = 0 (0x0) (int) block.major = 11 (0xb) (int) info.capabilities = 'block storage.cdrom storage' (string) info.category = 'storage' (string) info.parent = '/org/freedesktop/Hal/devices/scsi_0_0_0_0' (string) block.device = '/dev/sr0' (string) block.is_volume = false (bool) block.have_scanned = false (bool) block.no_partitions = true (bool) linux.sysfs_path_device = '/sys/block/sr0' (string) linux.sysfs_path = '/sys/block/sr0' (string) info.bus = 'block' (string)

based on what you're saying, it seems as tho hal is not seeing your cd drive at all. i have what you showed in your post as well, but that is just the ide interface.

the key you want to look for is: storage.policy.desired_mount_point = 'cdrom' . it doesn't make sense why hal can't find it. what version are you using? i'm guessing you emerged the latest.

here's what i'm using, in case there's some difference (but like i said, this has been working for awhile for me):
Code:
[ebuild R ] sys-apps/hal-0.4.8 -debug -doc -livecd +pcmcia 0 kB [ebuild R ] sys-apps/dbus-0.23.4-r1 -X -debug -gtk -mono +python -qt +xml2 0 kB

one final thing i suggest trying is 'dbus-monitor --system'. i bet you did that already tho... anyhow, this program will show you every little msg being sent about whats going on in your computer hardware wise. so if you insert a cd, it should indicate something happened.

i hope i'm helping at least a little, it seems as though you know what you're doing, so i'm sure you'll get it working soon.
ruzzmon is offline   Reply With Quote
Old 10-03-2005, 09:51 AM   #10
Low Bitrate
 
Join Date: Sep 2005
Posts: 80
My Photos: (0)
Quote: Originally Posted by ruzzmon
This is what my cd drive looks like in hal, w/o a cd in it. I'll try to get you an output of what lshal looks like w/a DVD in it. keep in mind that i have a firewire bridge going to a pcmcia firewire card, so thats where the scsi and ieee1394 stuff comes from

Hmm... on my desktop at work (FC3) that's the same stuff I see. It doesn't seem to detect the low-level tray open/close (immediate button press), but it DOES detect the new media a second or two after I insert the CD. So if I could just get my Gentoo machine to do the same, that would be great. I wonder why lshal doesn't even see my cd drive?

Oh well, this isn't even my car PC (I haven't bought that yet). It's just my development machine... and it's linux support is pretty shoddy. So.. maybe a world recompile might help (ughhh), or maybe I could try emerging an older version. If that doesn't work I'll just wait until I get my EPIA to mess with it.
gentoocar is offline   Reply With Quote
Sponsored Links
Old 10-03-2005, 10:28 AM   #11
FLAC
 
TheLlama's Avatar
 
Join Date: Jul 2004
Location: All over the world
Vehicle: 2001 Paper Airplane Standard Edition
Posts: 984
My Photos: (0)
I don't know, but I'd like to mention sysfs vs udev. I found alot of things would not work with sysfs, which is part of the reason why I switched to udev. Other times, I might have some software configured for sysfs but it wouldn't work because I just switched to udev.

Worth checking out I suppose. If I'm off-the-wall then just ignore me.
TheLlama is offline   Reply With Quote
Old 10-04-2005, 01:27 PM   #12
Newbie
 
Join Date: Dec 2004
Posts: 48
My Photos: (0)
ever tried AUTOFS?

http://gentoo-wiki.com/HOWTO_Auto_mo...ystems_(AUTOFS)

I just enter the /mnt/cdrom directory and linux mounts the cdrom for me then I just hit the eject button on the cdrom and it unmounts it and ejects the cd

Last edited by DigitalExpl0it; 10-04-2005 at 01:40 PM.
DigitalExpl0it is offline   Reply With Quote
Old 10-04-2005, 02:02 PM   #13
Variable Bitrate
 
intuitionsys's Avatar
 
Join Date: Jul 2005
Location: Ottawa, ON, Canada
Vehicle: 2005 Ford Freestar Limited
Posts: 288
My Photos: (0)
Quote: Originally Posted by TheLlama
I don't know, but I'd like to mention sysfs vs udev. I found alot of things would not work with sysfs, which is part of the reason why I switched to udev. Other times, I might have some software configured for sysfs but it wouldn't work because I just switched to udev.

Worth checking out I suppose. If I'm off-the-wall then just ignore me.

I can pretty much echo that. udev is married to the SuSE distro but I'm a Gentoo-lover right now so my sentiments may change in the future Anyhoo I'm beginning to ramble...
__________________
Silverwolf 2.0 Progress: 100% (alpha)
Alpha Release Date: June 28, 2007
intuitionsys is offline   Reply With Quote
Sponsored Links
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I setup the CD Rip plugin ? guino RR FAQ 1 09-21-2005 11:38 AM
P.I.E. Sony Dual CD Changer Interface & Auxiliary Input Chita79 Classified Archive 0 09-17-2005 03:22 PM
Help! WRX2001 PhoneControl 3 01-25-2005 03:50 PM
FOR SALE - ICE - Clarion Top End Mini Disc & CD changer Paul_GPvR Classified Archive 0 01-21-2005 05:28 AM
Standby while playing cd on firewire cd player psyclobe Media Engine 0 06-02-2004 11:10 PM


All times are GMT -5. The time now is 09:34 AM.


Sponsored Links
The MP3car.com Store

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Copyright © 1999 - 2008 Mp3Car.com Inc.
Ad Management by RedTyger
Message Board Statistics