View Single Post
Old 01-06-2007, 09:29 PM   #11 (permalink)
rivviepop
BlackBerry Extraordinaire
 
rivviepop's Avatar
 
Join Date: Dec 2006
Location: san francisco
Model: 8320
PIN: n/a
Carrier: t-mobile
Posts: 2,166
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey guys -- been working a little with Chris (barry/bcharge author) feeding him USB snoop logs and such. He gave me a one-line addition to the patch (as well as a new bcharge.cc that support Pearl *and* non-Pearl) which makes it work on first plug-in; you no longer need to plug it in, unplug, then plug again. With this fix it'll flash that initial "non enough power" message on your Pearl but then go away after a second (i.e. after bcharge fires up and adjusts the power flow).

Code:
diff -uNr barry-0.1-orig/10-blackberry.rules barry-0.1/10-blackberry.rules
--- barry-0.1-orig/10-blackberry.rules  2006-12-21 11:59:46.000000000 -0800
+++ barry-0.1/10-blackberry.rules       2007-01-06 18:46:19.000000000 -0800
@@ -1,3 +1,3 @@
 # Blackberry devices
 #
-BUS=="usb", ACTION=="add", SYSFS{idVendor}=="0fca", SYSFS{idProduct}=="0001", SYMLINK+="bb-%k", RUN="/usr/sbin/bcharge"
+BUS=="usb", ACTION=="add", SYSFS{idVendor}=="0fca", SYSFS{idProduct}=="0006", SYMLINK+="bb-%k", RUN="/usr/sbin/bcharge"
diff -uNr barry-0.1-orig/bcharge.cc barry-0.1/bcharge.cc
--- barry-0.1-orig/bcharge.cc   2006-12-21 11:40:31.000000000 -0800
+++ barry-0.1/bcharge.cc        2007-01-06 18:47:27.000000000 -0800
@@ -4,6 +4,15 @@
 ///            to 500mA.  Cycles through all devices attached to USB,
 ///            attempting to set all matching Blackberry devices to charge.
 ///
+///            This file is part of the Barry project:
+///
+///            http://www.netdirect.ca/software/packages/barry/index.php
+///            http://sourceforge.net/projects/barry
+///
+///            Compile with the following command (needs libusb):
+///
+///            g++ -o bcharge bcharge.cc -lusb
+///
 
 /*
     Copyright (C) 2006, Net Direct Inc. (http://www.netdirect.ca/)
@@ -27,6 +36,7 @@
 
 #define VENDOR_RIM             0x0fca
 #define PRODUCT_RIM_BLACKBERRY 0x0001
+#define PRODUCT_RIM_PEARL      0x0006
 
 #define BLACKBERRY_INTERFACE           0
 #define BLACKBERRY_CONFIGURATION       1
@@ -48,6 +58,7 @@
        sleep(3);
 
        // cleanup
+       usb_reset(handle);
        usb_close(handle);
 }
 
@@ -70,7 +81,8 @@
                for (dev = bus->devices; dev; dev = dev->next) {
                        // Is this a blackberry?
                        if( dev->descriptor.idVendor == VENDOR_RIM &&
-                           dev->descriptor.idProduct == PRODUCT_RIM_BLACKBERRY ) {
+                           (dev->descriptor.idProduct == PRODUCT_RIM_BLACKBERRY ||
+                            dev->descriptor.idProduct == PRODUCT_RIM_PEARL) ) {
                                printf("Found...");
                                if( dev->config &&
                                    dev->descriptor.bNumConfigurations >= 1 &&
The magic line in this case is that call to usb_reset(). According to Chris:

Quote:
Originally Posted by Chris Frey
On Blackberries I've tested, it resets itself automatically when the
special commands are given. Even udev detects this and runs bcharge again,
which is why I had to put in the 500mA check, or it would run forever.

Looks like the Pearl waits to be reset, which is more sane behaviour
in my opinion.
Offline