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

[coldsync-hackers] Re: USB m50x under FreeBSD



[This message exceeded the 40000-byte message length limit and
bounced. I'm including just the text portion.]

	I've finally torn myself away from Black & White long enough
to apply Koen Deforche's m50x patch and incorporate it into the
development branch. It's at:
http://www.ooblick.com/software/coldsync/coldsync-2.1.4-devel-20010728.tar.gz

	The main other difference in this branch is that "libpconn"
and "libpdb" are making baby steps toward becoming separate packages.

On Sat, Jul 28, 2001 at 04:36:55AM -0000, "Mike Durian" wrote:
> I'm trying to adapt the patch from Koen Deforche so it will work
> under FreeBSD as well as Linux and am running into difficulties.
> I've tried to abstract the difference between the FreeBSD USB
> interface and the Linux USB interface into separate areas leaving
> PConnection_usb.c and PConnection_usbm50x.c OS neutral.
>
> I didn't have much luck.  When I try to sync (an initalization request),
> I never get the first ritual message from the device.  I'm not
> terribly up on the FreeBSD USB interface and suspect I might
> have something wrong with the endpoint device detection, but I'm
> not sure.

	The thing is, USB devices under Linux are treated as serial
devices, thanks to a kernel module that makes a USB device look like a
serial port. Under FreeBSD, however, ColdSync talks USB directly to
the appropriate USB devices.

	Fortunately, I think the stuff in libpconn is reasonably
modular. Currently, for a normal USB connection (e.g., Visor), the
protocol stack looks like this under FreeBSD:

	DLP
	PADP
	SLP
	USB

For an M50x, you want 

	DLP
	netsync (no header)
	USB

There are methods in (struct PConnection) to do this: (*dlp.read)()
and (*dlp.write)() point to functions for reading/writing DLP packets.
(*io_read)() and (*io_write)() point to functions for reading
from/writing to the device.
	So it should be sufficient (yeah, right. As if it's ever that
simple!) to set
	pconn->dlp.read  = netsync_read;
	pconn->dlp.write = netsync_write;
	pconn->io_read   = usb_read;
	pconn->io_write  = usb_write;


	Having said this, I'm now thinking that adding a new
"usb_m50x" listen type was the wrong approach. Better to make that a
modifier of the listen block. That is, the listen{} block in
.coldsyncrc should take a "protocol:" option. Thus, under Linux, if
you have a plain Visor, you'd use

	listen serial {
		device: /dev/ttyUSB1;
	}

and for a m505, you'd use

	listen serial {
		device: /dev/ttyUSB;
		protocol: m50x;
	}

Likewise, under FreeBSD, you'd use "usb" instead of "serial".
	The obvious way to implement this would be to change

PConnection *new_PConnection(
	char *fname,
	int listenType,
	 int promptHotSync);
to

PConnection *new_PConnection(
	char *fname,
	int listenType,
	int protocol,
	int promptHotSync);

(where protocol == 0 means "pick a default"), and pass the protocol
argument to the various pconn_<listen-type>_open() functions.
	The way I see it, this way,

	listen Foo {
		device: /dev/palm;
		protocol: Bar;
	}

means that /dev/palm is a <Foo> device (serial port, USB port, TCP
connection, whatever), and that the cradle on /dev/palm understands
protocol Bar.

	IMHO, this should make it easier to incorporate future
protocol changes if and when Palm introduces them.

> I'm hoping someone can take a look at this and point out the
> stupid error I introduced when abstracting the code.

	Unfortunately, it looks as if you forgot to include the
"libpconn/usb_bsd.c" and "libpconn/usb_linux.c" files that are
mentioned in your patch. Since I suspect that's where the bulk of your
changes were, it's hard to make specific suggestions.

> This diff goes against a clean 2.1.3 distribution.  It includes
> Deforche's changes.  It also includes one unrelated (to USB)
> bug fix in netsync.c.  pconn->net.inbuf wasn't getting initialized
> to NULL which would cause problems with realloc if it held
> a non-zero value.

	I've incorporated the pconn->net.inbuf patch into the snapshot
above. Thanks!

> I appologize to any Linux users out there for typos I have in
> usb_linux.c.  Not having a Linux machine, I haven't been able
> to test compile the file.
> 
> Oh, I don't have a mime mail reader handy either - thus the
> shar attachment.

	You may want to use 'diff -ruN oldversion newversion'. With
the -N option, it'll include new files as diffs against an empty file.
Also, to cut down on the size of the patch, you can cut out the diffs
to the i18n/*.po files: if you haven't changed any of the
translations, those diffs are long and useless.

-- 
Andrew Arensburger                      This message *does* represent the
arensb@ooblick.com                      views of ooblick.com
		    Don't annoy the crazy person.
This message was sent through the coldsync-hackers mailing list.  To remove
yourself from this mailing list, send a message to majordomo@thedotin.net
with the words "unsubscribe coldsync-hackers" in the message body.  For more
information on Coldsync, send mail to coldsync-hackers-owner@thedotin.net.