View Single Post
Old 06-13-2011, 10:13 PM   #1
denverh
Enthusiast
denverh began at the beginning.
 
Posts: 25
Karma: 10
Join Date: May 2011
Device: prs-650
Device detection process

Hello,

I'm going to try adding the functions that are missing from the FreeBSD port. Those are all involved in detecting and mounting the reader when it's plugged in. It would help a bit if I understood the process for the Linux environment. It looks to me like /sys/devices is scanned for anything that matches the list of vendor and product IDs, but I'm not sure how this gets started, or where it goes from there. That's about as far as I've gotten so far. I don't have much experience with python, so this is going to be an interesting project.

If someone could describe, even briefly, the existing device detection and mounting process for Linux, I would greatly appreciate it.

Thanks,

Denver

June 14, 2010
Ok, I've fixed up the mount helper so it functions properly, and added some code to /devices/usbms/device.py to mount and eject the reader. Everything _seems_ to be working the way it should. The code in device.py is pretty basic right now: I hard-coded the device node and mount points. But that's just to see if everything else is working, and if I was missing anything. Here's the part I added for mounting the device (I shamelessly borrowed from the linux section):
Code:
  def open_freebsd(self):
                node="/dev/da1"
                label="READER"
                cmd = '/usr/local/bin/calibre-mount-helper'
                cmd = [cmd, 'mount']
                try:
                        p = subprocess.Popen(cmd + [node, '/media/'+label])
                except OSError:
                        raise DeviceError(
                        _('Could not find mount helper: %s.')%cmd[0])
                while p.poll() is None:
                        time.sleep(0.1)
                self._main_prefix = '/media/READER'
                self._card_a_prefix = None
                self._card_b_prefix = None
Is there anything else that's going to need to be done in there, besides the obvious? If not, then it looks like the next thing is to figure out a way to discover the device nodes.

Thanks,

Denver

Last edited by denverh; 06-14-2011 at 08:17 PM. Reason: update
denverh is offline   Reply With Quote