Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Lost packet when attempting a bulk read.



Hi Everyone:

I'm hoping someone can steer me in the right direction. I'm not exactly a USB development neophyte, but I am new to USB development on OS X. And while I've read all of the documentation and looked through all of the examples I can find, I'm running into a problem.

First off, here's what I'm trying to do. I'm the lead developer of the jSyncManager (http://www.jsyncmanager.org), a pure Java, Open Source API and toolset for synchronizing PalmOS-based handhelds. The project has been around for a long time, and has supported USB synchronization for quite a while, but typically requires either the Open Source jUSB API (http://jusb.sf.net), or the newer (and more standard) javax.usb API (http://www.javax-usb.org). The protocol stack is pure Java code.

As neither of these APIs currently exist on the Mac, I've decided to take it upon myself to write a JNI module to access USB on the Mac. Fortunately, the jSyncManager has always sported a plug-in interface for accessing the underlying data transports, so this sort of addition is pretty trivial, and doesn't require any modification to the protocol stack. I have lots of JNI experience, USB experience using the two Java USB APIs previously mentioned, and next to none with IOKit.

Here's my problem: I've written a preliminary version of my transport. It compiles fine, and appears to run fine. But for some reason, I'm losing the very first packet of the transfer.

Here's what is supposed to be going on in the USB layer: upon detecting the connection of a PalmOS-based device, we need to configure the device and find the two bulk transport pipes for the synchronization process (all of which is working very nicely BTW). Once we're initialized the interface (creating the pipes), we need to read a 6-byte packet, which is the header for the packet data to follow. The problem is, on the very first packet that 6-byte packet isn't being retrieved: I'm getting 22 bytes of packet data, without the header.

Currently I'm using the synchronous read calls, but I've also created a version of my code that uses the asynchronous system with the same results. I'm priming my buffer by reading a packet of data as soon as the pipes are initialized, so I can't imagine there being a timing problem.

    Here are the bytes I'm retrieving for the first packet:

90 01 00 00 00 00 00 00 | 00 20 00 00 00 08 00 00 | ......... ......
01 00 00 00 00 00 | ......


Here is what I'm actually expecting (from a capture taken using the same handheld from a Fedora Core 4 machine running the javax.usb API):

        01 FF 00 00 00 16

    ...followed by:

90 01 00 00 00 00 00 00 | 00 20 00 00 00 08 00 00 | ......... ......
01 00 00 00 00 00 | ......


As you can see, I'm getting the second 22 byte packet , but for some reason I'm not getting the first 6 byte packet containing the packet header.

Now I suppose I might be missing some control call to tell the interface to start sending data, which javax.usb is doing for me automatically, but this isn't apparent from the javax.usb sources. My other thought is that there is some sort of timing issue, and that the first packet is being lost and overwritten by the second packet before I have a chance to read it.

Does anyone have any advice? Other than this, the library appears to work correctly. I'm hoping to get this working soon, so if anyone has any helpful advice, please let me know!

(FYI, if anyone is sufficiently motivated to help on Open Source effort, the sources for my OS X USB Transport is available at: http://cvs.sourceforge.net/viewcvs.py/jsyncmanager/contrib/ osxusb_transport/).

Brad BARCLAY,
Lead Developer & Project Administrator,
The jSyncManager Project.

=-=-=-=-=-=-=-=-=-=
From the Mac OS X Desktop of Brad BARCLAY
E-Mail:  email@hidden     Web:  http://www.jsyncmanager.org


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.