<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Tom Moertel's Weblog: Tag centro</title>
    <link>http://blog.moertel.com/articles/tag/centro?tag=centro</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Quality rants on programming theory and stuff geeks like</description>
    <item>
      <title>How to download photos and movies from the Palm Centro to a Linux desktop</title>
      <description>&lt;p&gt;I recently got a Palm Centro smartphone, and so far I love it. Like
most modern cell phones, it has a built-in camera and takes decent
snapshots and even records short movies. It&amp;#8217;s great for
spur-of-the-moment shots when I don&amp;#8217;t have my real camera.  The
trick &amp;#8211; and there&amp;#8217;s always a trick when it comes to cell phones &amp;#8211; is getting
the photos off the camera and onto my computer.&lt;/p&gt;


	&lt;p&gt;To get at my pictures, Sprint would prefer that I sign up for their
ludicrously expensive &amp;#8220;PictureMail&amp;#8221; service.  Leave it to weasely
telecom execs to come up with another way to squeeze money from
teenagers: charge them $5 each month for the &amp;#8220;privilege&amp;#8221; of sharing
their pictures with friends.  This fee, of course, is in addition to the
fee for &amp;#8220;unlimited&amp;#8221; mobile Internet use.  I guess picture bits are
somehow more expensive to move over the air than other kinds of bits.&lt;/p&gt;


	&lt;p&gt;In any case, my next goal after
getting my &lt;a href="http://blog.moertel.com/articles/2007/10/31/how-to-hotsync-the-palm-centro-with-a-fedora-7-linux-desktop-via-usb"&gt;Centro to hotsync with my Linux
workstation&lt;/a&gt; was to figure out how
to download my photos and movies.&lt;/p&gt;


	&lt;p&gt;After a bit of hacking, I figured out that the Centro stores images in
a typical digital-camera-image (DCIM) hierarchy.  For
example, I have a 4-GB microSD card installed in my Centro, and I
store my photos in the &amp;#8220;Palm&amp;#8221; album on it.  This album ends up stored
in the /DCIM/Palm directory on the card.&lt;/p&gt;


	&lt;p&gt;Using the pilot-xfer program
from the &lt;a href="http://www.pilot-link.org/"&gt;pilot-link&lt;/a&gt; project, I was able
to find the directory and its contents.  The trick was to use the
sparsely documented &amp;#8211;D flag to work with the Centro&amp;#8217;s virtual
filesystem.  Here, for example, is how I list the contents of the Palm album:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;$ pilot-xfer -p usb: -D /DCIM/Palm -l

   Listening for incoming connection on usb:... connected!

   Directory of /DCIM/Palm...
        652 Fri Nov  2 08:17:06 2007  Album.db
     292053 Fri Nov  2 09:04:20 2007  Photo_110207_001.jpg
      78493 Fri Nov  2 08:17:06 2007  Video_110207_001.3g2
         20 Wed Oct 31 12:09:20 2007  Thumbnail.db

   Thank you for using pilot-link.
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Here, you can see that I have one photo and one movie in the album.
(Movies are stored in .3g2 files that contain &lt;span class="caps"&gt;MPEG4&lt;/span&gt; video.)&lt;/p&gt;


	&lt;p&gt;To download the files, I again turned to pilot-xfer, this time using the
&amp;#8211;f (fetch) flag to fetch a list of files.
Here, for example, I&amp;#8217;ll fetch the image from the listing above:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;$ pilot-xfer -p usb: -D /DCIM/Palm -f Photo_110207_001.jpg

   Listening for incoming connection on usb:... connected!

   Fetching '/DCIM/Palm' ... (292053 bytes)   285 KiB total.

   Thank you for using pilot-link.
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;So that&amp;#8217;s the process.  It&amp;#8217;s kind of clunky, so I wrote a small Python
program to automate it.  (I&amp;#8217;m learning Python.  If you&amp;#8217;re a Pythonista, please
consider critiquing my code. I would be especially thankful if you
could point out any helpful idioms that I may have overlooked.)&lt;/p&gt;


	&lt;p&gt;Here&amp;#8217;s how to use the program:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;$ get-pilot-photos.py --help
Usage: get-pilot-photos.py [options]

Options:
  -h, --help            show this help message and exit
  -s SRCDIR, --srcdir=SRCDIR
                        VFS dir on Palm device from which to fetch images
  -d DESTDIR, --destdir=DESTDIR
                        Where to save the images on your computer
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Both the &amp;#8212;srcdir and &amp;#8212;dstdir options are optional.  If you
omit the first, the program will download photos and movies from the
/DCIM/Palm album.  If you omit the second, the program will save the
downloads to a new, timestamped directory within your home directory.&lt;/p&gt;


	&lt;p&gt;That&amp;#8217;s it.  The code is below.&lt;/p&gt;&lt;pre&gt;&lt;code style="font-size: smaller"&gt;#!/usr/bin/env python

# get-pilot-photos.py -
# Download photos and movies from my Palm Centro via pilot-link
#
# Tom Moertel &amp;lt;tom@moertel.com&amp;gt;
# 2007-11-01
#
# Copyright 2007 Thomas G. Moertel
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# See &amp;lt;http://www.gnu.org/licenses/&amp;gt; for more.

import os
import optparse
import re
import subprocess
import time

PILOT_XFER = 'pilot-xfer'
DEFAULT_PALM_IMAGE_DIR = '/DCIM/Palm'

class PhotoImporter(object):

    def __init__(self, src_dir, dest_dir=None):
        self.src_dir = src_dir
        self.dest_dir = dest_dir or self.get_image_dir()

    def run(self):
        print 'Finding images in %s on your Palm device.' % self.src_dir
        print 'Begin hotsync now...'
        images = self.get_image_list()
        if len(images) == 0:
            print 'No images were found.  Done.'
            return
        print 'Found %s images' % len(images)
        print 'Waiting for hotsync to complete...'
        time.sleep(10) # give 1st hotsync time to complete
        print 'Begin another hotsync now...'
        self.fetch_images(images)
        print 'Done.  The images were fetched to the following directory:'
        print self.dest_dir

    def get_image_list(self):
        cmdline = [PILOT_XFER, '-p',  'usb:', '-D', self.src_dir, '-l']
        proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
        listing = proc.stdout.read()
        proc.wait()
        return re.findall(r'\b\S+\.(?:jpg|3g2)\b', listing)

    def fetch_images(self, images):
        cmdline = [PILOT_XFER, '-p',  'usb:', '-D', self.src_dir, '-f'] + images
        subprocess.Popen(cmdline, cwd=self.dest_dir).wait()

    def get_image_dir(self):
        root = os.getenv('HOME') or tempfile.mkdtemp()
        now = time.strftime("%Y-%m-%d--%H.%M.%S", time.localtime())
        dir = os.path.join(root, 'images', 'unsorted-pix', now)
        os.makedirs(dir, mode=0771)
        return dir

def main():
    p = optparse.OptionParser()
    p.add_option('--srcdir', '-s', default=DEFAULT_PALM_IMAGE_DIR,
                 help='VFS dir on Palm device from which to fetch images')
    p.add_option('--destdir', '-d',
                 help='Where to save the images on your computer')
    opts, args = p.parse_args()
    PhotoImporter(opts.srcdir, opts.destdir).run()

if __name__ == '__main__':
    main()
&lt;/code&gt;&lt;/pre&gt;</description>
      <pubDate>Fri, 02 Nov 2007 15:32:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:92fcb359-e7e8-41dc-a5b9-86caffcde1f5</guid>
      <author>Tom Moertel</author>
      <link>http://blog.moertel.com/articles/2007/11/02/how-to-download-photos-and-movies-from-the-palm-centro-to-a-linux-desktop</link>
      <category>hacks</category>
      <category>movies</category>
      <category>palm</category>
      <category>centro</category>
      <category>hotsync</category>
      <category>images</category>
      <category>download</category>
      <category>python</category>
      <trackback:ping>http://blog.moertel.com/articles/trackback/616</trackback:ping>
    </item>
    <item>
      <title>How to hotsync the Palm Centro with a Fedora 7 Linux desktop via USB</title>
      <description>&lt;p&gt;I just got a Palm Centro smartphone, and I love it. Getting it to sync
with my Linux workstation, however, was tricky, so I&amp;#8217;m posting this
recipe in hopes that it might save you some time.&lt;/p&gt;


	&lt;p&gt;The &amp;#8220;visor&amp;#8221; kernel driver is supposed to make compatible Palm
handhelds look like serial devices when attached via a &lt;span class="caps"&gt;USB&lt;/span&gt; cable.  For
me, it didn&amp;#8217;t work.  Instead, I had to blacklist the driver and
then use libusb to talk to the Centro.  Here&amp;#8217;s the recipe:&lt;/p&gt;


	&lt;p&gt;First, blacklist the &amp;#8220;visor&amp;#8221; kernel driver:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;# echo blacklist visor &amp;gt;&amp;gt; /etc/modprobe.conf
# modprobe -qr visor
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Second, make sure libusb is installed:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;# yum install libusb
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Third, edit the system&amp;#8217;s udev rules to make sure your user account can
access the device files used to talk to the Centro.  On my Fedora 7
setup, I found the right rule in /etc/udev/rules.d/50-udev.rules:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;ACTION=="add", SUBSYSTEM=="usb_endpoint", \
ATTR{bEndpointAddress}=="?*", ATTRS{devnum}=="?*", ATTRS{busnum}=="?*", \
NAME="bus/usb/$attr{busnum}/$attr{devnum}_ep/$attr{bEndpointAddress}", \
MODE="0644", SYMLINK+="%k" 
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;I edited the last line of the rule, changing the mode to 0664 and adding
a &lt;span class="caps"&gt;GROUP&lt;/span&gt; key to assign the Centro devices to my exclusive user group:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;MODE="0664", SYMLINK+="%k", GROUP="thor" 
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;This change lets my account talk to the Centro without having to
take on root privileges. (For bonus points you could set up a more-specific rule to match just your Centro. The rule above, as is, will actually match other devices, too.)&lt;/p&gt;


	&lt;p&gt;Fourth, tell udev to reload the rules:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;# udevcontrol reload_rules
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Finally, set up a Palm-device connection via gnome-pilot.  Be sure to
select &lt;span class="caps"&gt;USB&lt;/span&gt; for the Type and &amp;#8220;usb:&amp;#8221; from the Device drop-down list.&lt;/p&gt;


	&lt;p&gt;That&amp;#8217;s it.  If you&amp;#8217;re lucky like me, you should now be ready to
hotsync your Palm Centro!&lt;/p&gt;


&lt;div class="update"&gt;

	&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Even better, &lt;a href="http://howto.pilot-link.org/bluesync/index.html"&gt;this handy &lt;span class="caps"&gt;HOWTO&lt;/span&gt;&lt;/a&gt; shows you to
sync via Bluetooth, which is more convenient than hooking up a &lt;span class="caps"&gt;USB&lt;/span&gt;
cable.  I&amp;#8217;m now using this method.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt; If you want to use &lt;span class="caps"&gt;USB&lt;/span&gt; to hotsync your Centro, there is a
method that&amp;#8217;s more convenient than setting up udev rules.  Just create a perms file for
pam_console_apply that tells it to give the console user permission to
access your Centro.  To do so, create a file
/etc/security/console.perms.d/60-libpisock.perms and put the following in it:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&amp;lt;libpisock&amp;gt;=/dev/usbdev* /dev/bus/usb/[0-9]*/[0-9]*
&amp;lt;console&amp;gt; 0644 &amp;lt;libpisock&amp;gt; 0644 root
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;That&amp;#8217;s it. (You&amp;#8217;ll still need to use libusb.)&lt;/p&gt;


&lt;/div&gt;</description>
      <pubDate>Wed, 31 Oct 2007 00:35:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:32b55049-6f05-4eae-8d46-3c1c350afa4f</guid>
      <author>Tom Moertel</author>
      <link>http://blog.moertel.com/articles/2007/10/31/how-to-hotsync-the-palm-centro-with-a-fedora-7-linux-desktop-via-usb</link>
      <category>linux</category>
      <category>linux</category>
      <category>fedora</category>
      <category>palm</category>
      <category>centro</category>
      <category>hotsync</category>
      <category>usb</category>
      <trackback:ping>http://blog.moertel.com/articles/trackback/608</trackback:ping>
    </item>
  </channel>
</rss>
