gnome-pilot-2.0.14pre4 testing and fixes



This weekend, I finally got a chance to try gnome-pilot 2.0.14pre4. I found some problems with it,
which were easy to fix. See the attached patch.

The problems found:
1) usb.vendor_id and usb.product_id should have been usb_device.vendor_id and
usb_device.product_id, when getting values from HAL
2) The string used to match devices in devices.xml wasn't being formulated properly - the format
string needed to be "%04x" instead of "%4x" for the leading 0's.
3) When using HAL with either pilot-link 0.11.8 or 0.12pre4, pi_bind would fail. The reason for
this is most likely due to HAL notifying gpilotd that a device has been attached before udev has a
chance to actually create the device files. I've put in a while() loop to wait until the device
files have been created. It will timeout after 1 second (i.e. udev has 1 second to create the
device file - my tests showed it usually took a few milliseconds at most).

I also had to get a file from HAL's CVS repository: classdev.c. Without it, HAL 0.5.7 would
recognize the device, but fail to probe it (you can't probe a USB device using a serial probe
method). While I think gpilotd would still have worked (I found the HAL change before the gpilotd
changes), I think it's wise to use a CVS version of HAL if possible.

With these changes to gpilotd, I have had no troubles whatsoever in synchronizing. The only
conduit I'm currently able to use is the backup one, as the other conduits have not been converted
to the new API. Matt, will you be converting these? 

Also, the Evolution conduits will need to be converted. I believe there's a patch for the EAddress
conduit floating around out there right now. I plan on doing those conduits myself, since I use
Evolution a lot and I haven't seen any talk about them on the evo-hackers list lately.

BTW, here are the versions of software I'm running:
hal 0.5.7, slightly modified (classdev.c from CVS)
udev-092-2mdk (Mandriva-patched version)
dbus-0.61-5mdk (Mandriva-patched version)
pilot-link 0.12pre4, from Mark Adam's website
gnome-pilot-2.0.14pre4 - from Matt Davey's gnome-pilot download page.
kernel 2.6.16-1mdk-i686-up-4GB - base 2.6.16 kernel with alsa and 3rd party driver updates

Let me know what you think of the patch. I'll let the list know if I find anything else.

Nathan

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
--- gnome-pilot-2.0.14pre4/gpilotd/gpilotd.c	2006-04-25 05:05:36.000000000 -0400
+++ gnome-pilot-2.0.14pre4.modified/gpilotd/gpilotd.c	2006-05-29 15:08:42.000000000 -0400
@@ -138,6 +138,9 @@
 static int 
 pilot_connect (GPilotDevice *device,int *error) 
 {
+#define MAX_TIME_FOR_PI_BIND 1000000 /* 1 second, or 1,000,000 usec. */
+#define SLEEP_TIME_FOR_PI_BIND 1000 /* 1 ms, or 1,000 usec. */
+	
 #ifndef PILOT_LINK_0_12
 	struct pi_sockaddr addr;
 	union {
@@ -147,6 +150,8 @@
 #endif
 	int sd, listen_sd, pf;
 	int ret;
+
+	int time_elapsed_pi_bind = 0;
 	
 	if (device->type != PILOT_DEVICE_NETWORK) {
 		pilot_set_baud_rate (device);
@@ -194,14 +199,32 @@
 			return -1;
 		}
 
+		
+		/* 
+		 * When using HAL and USB, the ttyUSB[01] device files are
+		 * not created until after Hal has notified gpilotd that
+		 * a file exists. This causes pi_bind to fail.
+		 * To prevent a failure (and therefore sync), retry pi_bind
+		 * for up to the time allotted, sleeping a little in-between
+		 * tries.
+		 */
+		
+		time_elapsed_pi_bind = 0;
+		do {
 #ifdef PILOT_LINK_0_12
-		ret = pi_bind (listen_sd, device->port);
+			ret = pi_bind (listen_sd, device->port);
 #else
-		addr.pi_family = PI_AF_PILOT;
-		strcpy (addr.pi_device,device->port);
-		addrp.pi_sockaddrp = &addr;
-		ret = pi_bind (listen_sd, addrp.sockaddrp, sizeof (addr));	
+			addr.pi_family = PI_AF_PILOT;
+			strcpy (addr.pi_device,device->port);
+			addrp.pi_sockaddrp = &addr;
+			ret = pi_bind (listen_sd, addrp.sockaddrp, sizeof (addr));	
 #endif
+			if(ret < 0) {
+				usleep(SLEEP_TIME_FOR_PI_BIND);
+				time_elapsed_pi_bind += SLEEP_TIME_FOR_PI_BIND;
+			}
+		} while(ret<0 && time_elapsed_pi_bind < MAX_TIME_FOR_PI_BIND);
+		
 		if (ret < 0) {
 			g_warning (_("Unable to bind to pilot"));
 			if (error)
@@ -864,7 +887,7 @@
 	xmlDoc *doc = NULL;
 	xmlNode *root, *node;
 	char *filename;
-	
+
 	if (vendor_product_ids)
 		return;
 	
@@ -955,20 +978,20 @@
 
 	dbus_error_init (&error);
 	vendor_id = libhal_device_get_property_int (hal_ctx, udi,
-	    "usb.vendor_id", &error);
+	    "usb_device.vendor_id", &error);
 	if(vendor_id == -1) {
 		g_warning ("Could not get usb vendor ID from hal: %s", error.message);
 		return;
 	}
 	product_id = libhal_device_get_property_int (hal_ctx, udi,
-	    "usb.product_id", NULL);
+	    "usb_device.product_id", NULL);
 	if(product_id == -1) {
 		g_warning ("Could not get usb product ID from hal: %s", error.message);
 		return;
 	}
 	
 	/* now look for a vendor/product match */
-	match_str = g_strdup_printf ("Vendor=%4x ProdID=%4x",
+	match_str = g_strdup_printf ("Vendor=%04x ProdID=%04x",
 	    vendor_id, product_id);
 	i = known_usb_device(match_str);
 	g_free(match_str);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]