Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: detect CD insertion

  1. #1
    Low Bitrate
    Join Date
    Sep 2005
    Posts
    82

    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

  2. #2
    Variable Bitrate
    Join Date
    Mar 2002
    Posts
    413
    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.

  3. #3
    Newbie
    Join Date
    Jun 2003
    Posts
    35
    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.

  4. #4
    FLAC TheLlama's Avatar
    Join Date
    Jul 2004
    Location
    All over the world
    Posts
    970
    second on ivman

  5. #5
    pkg
    pkg is offline
    Low Bitrate pkg's Avatar
    Join Date
    Apr 2005
    Location
    Arizona
    Posts
    96
    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

  6. #6
    Low Bitrate
    Join Date
    Sep 2005
    Posts
    82
    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?

  7. #7
    Newbie
    Join Date
    Jun 2003
    Posts
    35
    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

  8. #8
    Low Bitrate
    Join Date
    Sep 2005
    Posts
    82
    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)

  9. #9
    Newbie
    Join Date
    Jun 2003
    Posts
    35
    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.

  10. #10
    Low Bitrate
    Join Date
    Sep 2005
    Posts
    82
    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.

Page 1 of 2 12 LastLast

Similar Threads

  1. How do I setup the CD Rip plugin ?
    By guino in forum RR FAQ
    Replies: 2
    Last Post: 12-18-2008, 08:28 AM
  2. P.I.E. Sony Dual CD Changer Interface & Auxiliary Input
    By Chita79 in forum Classified Archive
    Replies: 0
    Last Post: 09-17-2005, 04:22 PM
  3. Help!
    By WRX2001 in forum PhoneControl
    Replies: 3
    Last Post: 01-25-2005, 04:50 PM
  4. FOR SALE - ICE - Clarion Top End Mini Disc & CD changer
    By Paul_GPvR in forum Classified Archive
    Replies: 0
    Last Post: 01-21-2005, 06:28 AM
  5. Standby while playing cd on firewire cd player
    By psyclobe in forum Media Engine
    Replies: 0
    Last Post: 06-03-2004, 12:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •