|
From: Krakora, R. V <rob...@de...> - 2007-08-08 19:46:34
|
Stephan:
Also, the following line needs to be changed from this...
num_packets =3D (size + packet_size - 1) / packet_size;
...to this as well.
num_packets =3D size / packet_size;
See function below...
static NTSTATUS create_urb(libusb_device_t *dev, URB **urb, int
direction,=20
int urb_function, int endpoint, int
packet_size,=20
MDL *buffer, int size)
{
USBD_PIPE_HANDLE pipe_handle =3D NULL;
int num_packets =3D 0;
int i, urb_size;
*urb =3D NULL;
if(!get_pipe_handle(dev, endpoint, &pipe_handle))
{
DEBUG_ERROR("create_urb(): getting endpoint pipe failed");
return STATUS_INVALID_PARAMETER;
}
/* isochronous transfer */
if(urb_function =3D=3D URB_FUNCTION_ISOCH_TRANSFER)
{
if (packet_size <=3D 0)
{
DEBUG_ERROR("create_urb(): invalid packet size =3D %d",
packet_size);
return STATUS_INVALID_PARAMETER;
}
/* L I N E T O F I X F R O M A B O V E ! ! ! */
/* num_packets =3D (size + packet_size - 1) / packet_size; */
/* F I X E D F R O M A B O V E ! ! ! */
num_packets =3D size / packet_size;
if (num_packets <=3D 0)
{
DEBUG_ERROR("create_urb(): invalid number of packets =3D %d",
num_packets);
return STATUS_INVALID_PARAMETER;
}
if(num_packets > 255)
{
DEBUG_ERROR("create_urb(): transfer size too large");
return STATUS_INVALID_PARAMETER;
}
urb_size =3D sizeof(struct _URB_ISOCH_TRANSFER)
+ sizeof(USBD_ISO_PACKET_DESCRIPTOR) * num_packets;
}
else /* bulk or interrupt transfer */
{
urb_size =3D sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER);
}
*urb =3D ExAllocatePool(NonPagedPool, urb_size);
if(!*urb)
{
DEBUG_ERROR("create_urb(): memory allocation error");
return STATUS_NO_MEMORY;
}
memset(*urb, 0, urb_size);
(*urb)->UrbHeader.Length =3D (USHORT)urb_size;
(*urb)->UrbHeader.Function =3D (USHORT)urb_function;
/* isochronous transfer */
if(urb_function =3D=3D URB_FUNCTION_ISOCH_TRANSFER)
{
(*urb)->UrbIsochronousTransfer.PipeHandle =3D pipe_handle;
(*urb)->UrbIsochronousTransfer.TransferFlags=20
=3D direction | USBD_SHORT_TRANSFER_OK |
USBD_START_ISO_TRANSFER_ASAP;
(*urb)->UrbIsochronousTransfer.TransferBufferLength =3D size;
(*urb)->UrbIsochronousTransfer.TransferBufferMDL =3D buffer;
(*urb)->UrbIsochronousTransfer.NumberOfPackets =3D num_packets;
for(i =3D 0; i < num_packets; i++)
{
(*urb)->UrbIsochronousTransfer.IsoPacket[i].Offset =3D i *
packet_size;
(*urb)->UrbIsochronousTransfer.IsoPacket[i].Length =3D
packet_size;
}
}
/* bulk or interrupt transfer */
else
{
(*urb)->UrbBulkOrInterruptTransfer.PipeHandle =3D pipe_handle;
(*urb)->UrbBulkOrInterruptTransfer.TransferFlags=20
=3D direction | USBD_SHORT_TRANSFER_OK;
(*urb)->UrbBulkOrInterruptTransfer.TransferBufferLength =3D size;
(*urb)->UrbBulkOrInterruptTransfer.TransferBufferMDL =3D buffer;
}
return STATUS_SUCCESS;
}
Best Regards,
Rob Krakora
Software Engineer
Delphi Electronics & Safety
e-mail: rob...@de...
phone: 765-451-8574
-----Original Message-----
From: lib...@li...
[mailto:lib...@li...] On Behalf Of
lib...@li...
Sent: Wednesday, August 08, 2007 3:11 PM
To: lib...@li...
Subject: Libusb-win32-devel Digest, Vol 15, Issue 2
Send Libusb-win32-devel mailing list submissions to
lib...@li...
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
or, via email, send a message with subject or body 'help' to
lib...@li...
You can reach the person managing the list at
lib...@li...
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Libusb-win32-devel digest..."
Today's Topics:
1. Simple Question for Libusb developer (Islam Beltagy)
2. Re: Libusb and Javax.usb (Stephan Meyer)
3. Re: Composite device - HID + custom (Stephan Meyer)
4. Re: Simple Question for Libusb developer (Stephan Meyer)
5. Re: Divide-by-zero error in driver causes BSD on Windows XP
SP2 (ste...@we...)
----------------------------------------------------------------------
Message: 1
Date: Wed, 8 Aug 2007 17:31:58 +0200
From: "Islam Beltagy" <is...@gm...>
Subject: [Libusb-win32-devel] Simple Question for Libusb developer
To: Lib...@li...
Message-ID:
<a1a...@ma...>
Content-Type: text/plain; charset=3D"iso-8859-1"
Hello,
I want to add asynchronous control submission to Libusb. does that can
be
simply done in the same way as in Bulk, Interrupt and Isochronous
submission
or there are hidden synchronization problems or any other problems that
I
did not notice???
Thank you,
Islam Beltagy
-------------- next part --------------
An HTML attachment was scrubbed...
------------------------------
Message: 2
Date: Wed, 08 Aug 2007 20:42:36 +0200
From: Stephan Meyer <ste...@we...>
Subject: Re: [Libusb-win32-devel] Libusb and Javax.usb
To: lib...@li...
Message-ID: <297...@we...>
Content-Type: text/plain; charset=3Diso-8859-15
transfer.c already has support for 'short packets'. The
USBD_SHORT_TRANSFER_OK
flag is explicitly set before submitting an URB.
Stephan
> Hello,=20
>=20
> I am working in Javax.Usb and trying to implement it for windows using
Libusb but some features are=20
> missing from Libusb, I am working in the things that I can do but some
others I can not.
>=20
> I need help in supporting "Short Packets" submission. All the changes
will be in the file transfer.c .=20
> If anyone can do that or help me, I will really appreciate that.
>=20
> Thanks
>=20
> Bye
>=20
> -----------------------------------------------------------------
>
------------------------------------------------------------------------
-
> 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/
>=20
> -----------------------------------------------------------------
> _______________________________________________
> Libusb-win32-devel mailing list
> Lib...@li...
> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>=20
_______________________________________________________________________
Jetzt neu! Sch?tzen Sie Ihren PC mit McAfee und WEB.DE. 3 Monate
kostenlos testen. http://www.pc-sicherheit.web.de/startseite/?mc=3D022220
------------------------------
Message: 3
Date: Wed, 08 Aug 2007 20:52:21 +0200
From: Stephan Meyer <ste...@we...>
Subject: Re: [Libusb-win32-devel] Composite device - HID + custom
To: lib...@li...
Message-ID: <297...@we...>
Content-Type: text/plain; charset=3Diso-8859-15
>=20
>=20
> Hello All!
>=20
> I'm developing gaming device for flight simulation.
> Part of the device is HID joystick, another part is custom
input(encoders,
> DACs, rotary switches, etc) and output (LED displays, PWM controlled
gauges,
> lamps, etc).
>=20
> Originally it was pure HID device with input and output reports
defind, but
> I've found that I need more data to be transferred in and out.=20
>=20
> So my goal is to use Windows driver for HID part and LibUSB for custom
part.
> In host application I'm going to use bulk read and writes.=20
>=20
> The first (and major) question is - it is possible to write the inf
file in
> a way where the HID part(&MI_00) is served by windows driver and the
custom
> part is served by LibUSB?
Yes that's possible. See
http://msdn2.microsoft.com/en-us/library/ms791091.aspx=20
for details.
=20
>=20
> The second question is actually regarding bulk transfer.
> The device(AT91SAM7S256) has 4 endpoints, 2 of them (planned to be
used by
> custom part) has size of 64 bytes. Also the endpoints support
ping-pong
> transfer.=20
>=20
> I plan to bulk transfer 256-512 bytes in one usb_bulk_write/read call
so I
> suppose that there will be 4-8 consequentive data out/in transactions.
The
> question is - will it work as expected or I can send no more than
maximum
> EP size in a time?
The amount of data you can send or receive at once is only limited
by the OS and/or your system's RAM.
>=20
> Thanks!
>=20
> Best regards,
> Konstantin Klubnichkin
> --=20
> View this message in context:
http://www.nabble.com/Composite-device---HID-%2B-custom-tf4229374.html#a
12031879
> Sent from the LibUSB Dev - Win32 mailing list archive at Nabble.com.
>=20
>=20
>
------------------------------------------------------------------------
-
> 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-win32-devel mailing list
> Lib...@li...
> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>=20
________________________________________________________________________
______
Jetzt neu! Im riesigen WEB.DE Club SmartDrive Dateien freigeben und mit=20
Freunden teilen!
http://www.freemail.web.de/club/smartdrive_ttc.htm/?mc=3D021134
------------------------------
Message: 4
Date: Wed, 08 Aug 2007 21:02:48 +0200
From: Stephan Meyer <ste...@we...>
Subject: Re: [Libusb-win32-devel] Simple Question for Libusb developer
To: lib...@li...
Message-ID: <297...@we...>
Content-Type: text/plain; charset=3Diso-8859-15
Adding the feature should not be that difficult if you are
familiar with Windows kernel driver programming.
But I can't imagine any real world application that would
benefit from such a feature. What are you planning to do?
Stephan
> Hello,=20
>=20
> I want to add asynchronous control submission to Libusb. does that can
be simply done in the same=20
> way as in Bulk, Interrupt and Isochronous submission or there are
hidden synchronization problems=20
> or any other problems that I did not notice???
>=20
>=20
> Thank you,
>=20
> Islam Beltagy
>=20
> -----------------------------------------------------------------
>
------------------------------------------------------------------------
-
> 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/
>=20
> -----------------------------------------------------------------
> _______________________________________________
> Libusb-win32-devel mailing list
> Lib...@li...
> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>=20
_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=3D100071&distributionid=3D000000000066
------------------------------
Message: 5
Date: Wed, 08 Aug 2007 21:10:38 +0200
From: ste...@we...
Subject: Re: [Libusb-win32-devel] Divide-by-zero error in driver
causes BSD on Windows XP SP2
To: lib...@li...
Message-ID: <297...@we...>
Content-Type: text/plain; charset=3Diso-8859-15
Thanks for the patch, Rob! I'll add this soon.
Stephan
>=20
> >=20
> > I had to fix the code that comprises the function create_urb() in
the
> > file transfer.c for proper handling of the packet_size parameter for
> > isochronous reads (see below). Also, I added proper handling for
> > num_packets as well. I had previously neglected to fill in
packet_size
> > prior to this fix and zero was being passed in as packet_size
resulting
> > in a divide-by-zero error in the driver and the BSD.
> >=20
> >=20
> > static NTSTATUS create_urb(libusb_device_t *dev, URB **urb, int
> > direction,=20
> > int urb_function, int endpoint, int
> > packet_size,=20
> > MDL *buffer, int size)
> > {
> > USBD_PIPE_HANDLE pipe_handle =3D NULL;
> > int num_packets =3D 0;
> > int i, urb_size;
> >=20
> > *urb =3D NULL;
> >=20
> > if(!get_pipe_handle(dev, endpoint, &pipe_handle))
> > {
> > DEBUG_ERROR("create_urb(): getting endpoint pipe failed");
> > return STATUS_INVALID_PARAMETER;
> > }
> >=20
> > /* isochronous transfer */
> > if(urb_function =3D=3D URB_FUNCTION_ISOCH_TRANSFER)
> > {
> > if (packet_size <=3D 0)
> > {
> > DEBUG_ERROR("create_urb(): invalid packet size =3D %d",
> > packet_size);
> > return STATUS_INVALID_PARAMETER;
> > }
> >=20
> > num_packets =3D (size + packet_size - 1) / packet_size;
> >=20
> > if (num_packets <=3D 0)
> > {
> > DEBUG_ERROR("create_urb(): invalid number of packets =3D
%d",
> > num_packets);
> > return STATUS_INVALID_PARAMETER;
> > }
> >=20
> > if(num_packets > 255)
> > {
> > DEBUG_ERROR("create_urb(): transfer size too large");
> > return STATUS_INVALID_PARAMETER;
> > }
> >=20
> > urb_size =3D sizeof(struct _URB_ISOCH_TRANSFER)
> > + sizeof(USBD_ISO_PACKET_DESCRIPTOR) * num_packets;
> > }
> > else /* bulk or interrupt transfer */
> > {
> > urb_size =3D sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER);
> > }
> >=20
> > *urb =3D ExAllocatePool(NonPagedPool, urb_size);
> >=20
> > if(!*urb)
> > {
> > DEBUG_ERROR("create_urb(): memory allocation error");
> > return STATUS_NO_MEMORY;
> > }
> >=20
> > memset(*urb, 0, urb_size);
> >=20
> > (*urb)->UrbHeader.Length =3D (USHORT)urb_size;
> > (*urb)->UrbHeader.Function =3D (USHORT)urb_function;
> >=20
> > /* isochronous transfer */
> > if(urb_function =3D=3D URB_FUNCTION_ISOCH_TRANSFER)
> > {
> > (*urb)->UrbIsochronousTransfer.PipeHandle =3D pipe_handle;
> > (*urb)->UrbIsochronousTransfer.TransferFlags=20
> > =3D direction | USBD_SHORT_TRANSFER_OK |
> > USBD_START_ISO_TRANSFER_ASAP;
> > (*urb)->UrbIsochronousTransfer.TransferBufferLength =3D size;
> > (*urb)->UrbIsochronousTransfer.TransferBufferMDL =3D buffer;
> > (*urb)->UrbIsochronousTransfer.NumberOfPackets =3D num_packets;
> >=20
> > for(i =3D 0; i < num_packets; i++)
> > {
> > (*urb)->UrbIsochronousTransfer.IsoPacket[i].Offset =3D i *
> > packet_size;
> > (*urb)->UrbIsochronousTransfer.IsoPacket[i].Length =3D
> > packet_size;
> > }
> > }
> > /* bulk or interrupt transfer */
> > else
> > {
> > (*urb)->UrbBulkOrInterruptTransfer.PipeHandle =3D pipe_handle;
> > (*urb)->UrbBulkOrInterruptTransfer.TransferFlags=20
> > =3D direction | USBD_SHORT_TRANSFER_OK;
> > (*urb)->UrbBulkOrInterruptTransfer.TransferBufferLength =3D
size;
> > (*urb)->UrbBulkOrInterruptTransfer.TransferBufferMDL =3D buffer;
> > }
> >=20
> > return STATUS_SUCCESS;
> > }
> >=20
> > Rob Krakora
> > Software Engineer
> > Delphi Electronics & Safety
> > e-mail: rob...@de...
> > phone: 765-451-8574
> >=20
> > -----Original Message-----
> > From: lib...@li...
> > [mailto:lib...@li...] On Behalf
Of
> > lib...@li...
> > Sent: Wednesday, July 25, 2007 3:04 PM
> > To: lib...@li...
> > Subject: Libusb-win32-devel Digest, Vol 14, Issue 10
> >=20
> > Send Libusb-win32-devel mailing list submissions to
> > lib...@li...
> >=20
> > To subscribe or unsubscribe via the World Wide Web, visit
> > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
> > or, via email, send a message with subject or body 'help' to
> > lib...@li...
> >=20
> > You can reach the person managing the list at
> > lib...@li...
> >=20
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of Libusb-win32-devel digest..."
> >=20
> >=20
> > Today's Topics:
> >=20
> > 1. Not working, vista32 (Carl Kenner)
> >=20
> >=20
> >
----------------------------------------------------------------------
> >=20
> > Message: 1
> > Date: Wed, 25 Jul 2007 22:08:39 +0930
> > From: "Carl Kenner" <car...@gm...>
> > Subject: [Libusb-win32-devel] Not working, vista32
> > To: lib...@li...
> > Message-ID:
> > <fab...@ma...>
> > Content-Type: text/plain; charset=3DISO-8859-1; format=3Dflowed
> >=20
> > Installing the latest filter driver (0.1.12.1) on my vista32 laptop
> > gives no error, but causes HID devices in device manager to have
error
> > 39, and the test program gives version -1,-1,-1,-1 for the driver
(but
> > gives the correct version for the dll).
> >=20
> > Uninstalling the filter driver makes it go back to normal.
> >=20
> > On the other hand, installing the device driver version (for the
Sony
> > SIXAXIS) gives no error, everything looks right in device manager,
and
> > the test program gives the right version. But it finds a single bus,
> > and no devices. Oh, and the inf file can't be installed by
> > right-clicking and choosing "install", it can only be installed with
> > Add New Hardware, All Devices, Have Disk.
> >=20
> > In case you are wondering, the SIXAXIS is a HID joystick device
which
> > doesn't describe itself correctly. It doesn't send any buttons or
axis
> > data until you read a specific feature report, but that feature
report
> > isn't listed as one it supports (although it does support/require
it),
> > so trying to read that feature report in windows with
HidD_GetFeature
> > always fails. Which is why I need libusb to work.
> >=20
> > So... WHY isn't libusb-win32 working for me? There is, literally,
zero
> > documentation, which doesn't help. I don't even know if it is
supposed
> > to work on Vista.
> >=20
> > And if you don't know how to fix the bugs in libusb-win32, do you
know
> > of any other way to read a feature report from a USB HID device
> > without using HidD_GetFeature?
> >=20
> >=20
> >=20
> > ------------------------------
> >=20
> >
------------------------------------------------------------------------
> > -
> > 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/
> >=20
> > ------------------------------
> >=20
> > _______________________________________________
> > Libusb-win32-devel mailing list
> > Lib...@li...
> > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
> >=20
> >=20
> > End of Libusb-win32-devel Digest, Vol 14, Issue 10
> > **************************************************
> >=20
> >=20
>
************************************************************************
****************
> >=20
> > Note: If the reader of this message is not the intended recipient,=20
> > or an employee or agent responsible for delivering this message to=20
> > the intended recipient, you are hereby notified that any=20
> > dissemination, distribution or copying of this communication is=20
> > strictly prohibited. If you have received this communication in=20
> > error, please notify us immediately by replying to the message and=20
> > deleting it from your computer. Thank you.=20
> >=20
> >=20
>
************************************************************************
****************
> >=20
> >=20
>
------------------------------------------------------------------------
-
> > 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-win32-devel mailing list
> > Lib...@li...
> > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>=20
>=20
_______________________________________________________________________
Jetzt neu! Sch?tzen Sie Ihren PC mit McAfee und WEB.DE. 3 Monate
kostenlos testen. http://www.pc-sicherheit.web.de/startseite/?mc=3D022220
------------------------------
------------------------------------------------------------------------
-
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-win32-devel mailing list
Lib...@li...
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
End of Libusb-win32-devel Digest, Vol 15, Issue 2
*************************************************
***************************************************************************=
*************
Note: If the reader of this message is not the intended recipient, or an=
employee or agent responsible for delivering this message to the intended=
recipient, you are hereby notified that any dissemination, distribution or=
copying of this communication is strictly prohibited. If you have received=
this communication in error, please notify us immediately by replying to=
the message and deleting it from your computer. Thank you.=20
***************************************************************************=
*************
|