osdir.com
mailing list archive

Subject: Isochronous transfer with libusb - msg#00031

List: lib.libusb.devel.general

Date: Prev Next Index Thread: Prev Next Index
I am now trying to test a simple isochronous USB device. Under Windows,
I can use libusb-win32 to do a simple test.
http://forum.microchip.com/tm.aspx?m=270049

I understand that I still need to understand more about isochronous
transfer and improve the firmware side but I am interested to test it
under libusb Linux as well with similar code.

What is my option under Linux with libusb since the current libusb
code does not support isochronous transfer. The existing patches
do not have a similar API like libusb-win32.

Thanks in advance.

Xiaofan

---------- Forwarded message ----------
From: Xiaofan Chen <xiaofanc@xxxxxxxxx>
Date: Jul 31, 2007 9:56 AM
Subject: Understanding iIsochronous transfer with libusb-win32
To: libusb-win32-devel@xxxxxxxxxxxxxxxxxxxxx

I am in the process of writing a simple isochronous transfer firmware for
Microchip PICkit 2 (PIC18F2550). I need a host application to test it.
http://forum.microchip.com/tm.aspx?m=270049&mpage=2

Based on some of the examples Stephan posted here, I come out the
following test program and it seems to work. However, I do not quite
understand the code since I do not quite understand isochronous transfer.
Why we need three context? What is the benefit? Now three buffers
contain the same data.

I know the firmware is not that useful yet since it does not implement
double buffer.

<code>
#include <usb.h>

#define VERSION "0.1.0"
#define VENDOR_ID 0x04D8
#define PRODUCT_ID 0x0080
#define INTERFACE 0
#define BUFFER_SIZE 65

usb_dev_handle *find_pickit2_isoc();

usb_dev_handle* setup_libusb_access() {
usb_dev_handle *pickit2_isoc;

usb_set_debug(255);
usb_init();
usb_find_busses();
usb_find_devices();

if(!(pickit2_isoc = find_pickit2_isoc())) {
printf("Couldn't find the mouse, Exiting\n");
return NULL;
}

if (usb_set_configuration(pickit2_isoc, 1) < 0) {
printf("Could not set configuration 1 : %s\n");
return NULL;
}

if (usb_claim_interface(pickit2_isoc, INTERFACE) < 0) {
printf("Could not claim interface: %s\n");
return NULL;
}

return pickit2_isoc;
}

usb_dev_handle *find_pickit2_isoc()
{
struct usb_bus *bus;
struct usb_device *dev;

for (bus = usb_busses; bus; bus = bus->next) {
for (dev = bus->devices; dev; dev = dev->next) {
if (dev->descriptor.idVendor == VENDOR_ID &&
dev->descriptor.idProduct == PRODUCT_ID ) {
usb_dev_handle *handle;
printf("pickit2_isoc with Vendor Id:
%x and Product Id: %x
found.\n", VENDOR_ID, PRODUCT_ID);
if (!(handle = usb_open(dev))) {
printf("Could not open USB device\n");
return NULL;
}

return handle;
}

}
}

return NULL;
}

void test_isochronous_async(usb_dev_handle *dev)
{
unsigned char buf0[640];
unsigned char buf1[640];
unsigned char buf2[640];

int i;

/* use three contexts for this example (more can be used) */
void *context0 = NULL;
void *context1 = NULL;
void *context2 = NULL;

/* write transfer (stream) */
/*
usb_isochronous_setup_async(dev, &context0, 0x01);
usb_isochronous_setup_async(dev, &context1, 0x01);
usb_isochronous_setup_async(dev, &context2, 0x01);

usb_submit_async(context0, buf0, sizeof(buf0));
usb_submit_async(context1, buf1, sizeof(buf1));
usb_submit_async(context2, buf2, sizeof(buf2));

for(i = 0; i < 10; i++)
{
usb_reap_async(context0, 5000);
usb_submit_async(context0, buf0, sizeof(buf0));

usb_reap_async(context1, 5000);
usb_submit_async(context1, buf1, sizeof(buf1));

usb_reap_async(context2, 5000);
usb_submit_async(context2, buf2, sizeof(buf2));
}

usb_reap_async(context0, 5000);
usb_reap_async(context1, 5000);
usb_reap_async(context2, 5000);

usb_free_async(&context0);
usb_free_async(&context1);
usb_free_async(&context2);

*/

/* read transfer (stream) */
usb_isochronous_setup_async(dev, &context0, 0x81,64);
usb_isochronous_setup_async(dev, &context1, 0x81,64);
usb_isochronous_setup_async(dev, &context2, 0x81,64);

usb_submit_async(context0, buf0, sizeof(buf0));
usb_submit_async(context1, buf1, sizeof(buf1));
usb_submit_async(context2, buf2, sizeof(buf2));

for(i = 0; i < 10; i++)
{
usb_reap_async(context0, 5000);
usb_submit_async(context0, buf0, sizeof(buf0));

usb_reap_async(context1, 5000);
usb_submit_async(context1, buf1, sizeof(buf1));

usb_reap_async(context2, 5000);
usb_submit_async(context2, buf2, sizeof(buf2));
}

for(i = 0; i < 640; i++) {
printf(" %02x, %02x, %02x ", buf0[i],buf1[i],buf2[i]);
// printf(" %02x, %02x, %02x ", buf0[i]);
}

usb_reap_async(context0, 5000);
usb_reap_async(context1, 5000);
usb_reap_async(context2, 5000);
usb_free_async(&context0);
usb_free_async(&context1);
usb_free_async(&context2);

/* release interface */
usb_set_altinterface(dev, 0);
usb_release_interface(dev, 0);
}


int main(void)
{
usb_dev_handle *pickit2_isoc;
if ((pickit2_isoc = setup_libusb_access()) == NULL) {
exit(-1);
}
test_isochronous_async(pickit2_isoc);
usb_close(pickit2_isoc);

return 0;
}


<device info>
DLL version: 0.1.12.1
Driver version: 0.1.12.1

bus/device idVendor/idProduct
bus-0/\\.\libusb0-0001--0x04d8-0x0080 04D8/0080
- Manufacturer : Microchip Technology Inc.
- Product : PICDEM FS USB Demo Board (C) 2004
wTotalLength: 32
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: 80h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: 0
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 01h
bmAttributes: 0dh
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 81h
bmAttributes: 0dh
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0

Regards,
Xiaofan

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/


Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: Request for information regarding Linux driver

Michael Bender wrote: > Peter Stuge wrote: > > >> However, I still don't see why ceasing the illegal distribution >> should be postponed until the next production version and not >> > > just done today, for all past and current versions using libusb. > > (That is, after all, what the license says.) > > I think that "ceasing illegal distribution today" is a lot easier > when you're just one guy in your bedroom cranking out code for fun. > When you work for an organization that has any semblance of code > control, QA and release engineering processes, you can't just turn > on a dime and put up new code willy-nilly. > > Besides, the folks at Touch-Base have been told of the license > issue, and it seems to me that they have responded that they > understand the issue and are working to make it right in their > upcoming release. What harm is there really to leaving their > existing code out there for a few weeks until their updated code > is ready for production? I mean, other than bothering a few wonks > that have nothing better to do than to self-gratify themselves > while pouring over the finer points of the GPL that is. > And remember this is the libusb project, not the glib sob project. Paul > mike > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Libusb-devel mailing list > Libusb-devel@xxxxxxxxxxxxxxxxxxxxx > https://lists.sourceforge.net/lists/listinfo/libusb-devel > ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

Next Message by Date: click to view message preview

Re: Request for information regarding Linux driver

This is getting to be a real yawn. On 8/17/07, Dave Bhattacharjee <dave@xxxxxxxxxxxxxx> wrote: > Not at all, but you described our software as "crap" because it did not > meet the "standards you expect". Making such a criticism without making > any effort (I am assuming, given the number of factual inaccuracies in > your previous email) Which factual inaccuracies? > to look at the overall picture (and given the > number of satisfied customers we have your judgement is clearly, at > best, subjective) is arrogant. Linux customers are *very* different from windows customers. You said that 99.9% of your customers are on windows. If that is the case, your statistical sampling of Linux users is almost certainly suspect. > You indicated that you wrote a driver for the Zypos controller and this > was relatively trivial having analysed the USB data stream. Fair enough, > but your later comments (to paraphrase; this was really easy, so why are > Touch-Base even bothering to distribute binaries) suggest that you think > the functionality of our software is equivalent to yours. No, I said they fit our purposes better than your driver. I won't be responding to any further emails on this subject. I am however still waiting to see your company fulfill its obligations under the terms of the LGPL. Paul ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

Previous Message by Thread: click to view message preview

2 questions (status & hiddev)

I, I've got two questions: - is libusb still maintained and developed on? (on all platforms) because I found version 0.1 and that seems to be it - is it a lot work to migrate a tool that talks to a hid-dev device on linux to one doing this via libusb? Folkert van Heusden -- Multitail est un outil permettant la visualisation de fichiers de journalisation et/ou le suivi de l'exécution de commandes. Filtrage, mise en couleur de mot-clé, fusions, visualisation de différences (diff-view), etc. http://www.vanheusden.com/multitail/ ---------------------------------------------------------------------- Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

Next Message by Thread: click to view message preview

libusb on Mac OS 10.4.9

I got the following message when I plug a Sandisk e280 into the USB port on my PBG4 running on Mac OS 10.4.9 AppleUSBEHCI[0x1f34000]::Found a transaction which hasn't moved in 5 seconds on bus 85, timing out! Sometimes the e280 connects succesfully with the mac, sometimes it does not and I get the USB error message. Is there any way to solve the problem? Thanks Jean ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by