|
From: Stephan M. <ste...@we...> - 2007-08-12 10:47:27
|
Patch applied, thanks!
>
>
> Stephan:
>
> Also, the following line needs to be changed from this...
>
> num_packets = (size + packet_size - 1) / packet_size;
>
> ...to this as well.
>
> num_packets = size / packet_size;
>
> See function below...
>
> static NTSTATUS create_urb(libusb_device_t *dev, URB **urb, int
> direction,
> int urb_function, int endpoint, int
> packet_size,
> MDL *buffer, int size)
> {
> USBD_PIPE_HANDLE pipe_handle = NULL;
> int num_packets = 0;
> int i, urb_size;
>
> *urb = 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 == URB_FUNCTION_ISOCH_TRANSFER)
> {
> if (packet_size <= 0)
> {
> DEBUG_ERROR("create_urb(): invalid packet size = %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 = (size + packet_size - 1) / packet_size; */
> /* F I X E D F R O M A B O V E ! ! ! */
> num_packets = size / packet_size;
>
> if (num_packets <= 0)
> {
> DEBUG_ERROR("create_urb(): invalid number of packets = %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 = sizeof(struct _URB_ISOCH_TRANSFER)
> + sizeof(USBD_ISO_PACKET_DESCRIPTOR) * num_packets;
> }
> else /* bulk or interrupt transfer */
> {
> urb_size = sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER);
> }
>
> *urb = 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 = (USHORT)urb_size;
> (*urb)->UrbHeader.Function = (USHORT)urb_function;
>
> /* isochronous transfer */
> if(urb_function == URB_FUNCTION_ISOCH_TRANSFER)
> {
> (*urb)->UrbIsochronousTransfer.PipeHandle = pipe_handle;
> (*urb)->UrbIsochronousTransfer.TransferFlags
> = direction | USBD_SHORT_TRANSFER_OK |
> USBD_START_ISO_TRANSFER_ASAP;
> (*urb)->UrbIsochronousTransfer.TransferBufferLength = size;
> (*urb)->UrbIsochronousTransfer.TransferBufferMDL = buffer;
> (*urb)->UrbIsochronousTransfer.NumberOfPackets = num_packets;
>
> for(i = 0; i < num_packets; i++)
> {
> (*urb)->UrbIsochronousTransfer.IsoPacket[i].Offset = i *
> packet_size;
> (*urb)->UrbIsochronousTransfer.IsoPacket[i].Length =
> packet_size;
> }
> }
> /* bulk or interrupt transfer */
> else
> {
> (*urb)->UrbBulkOrInterruptTransfer.PipeHandle = pipe_handle;
> (*urb)->UrbBulkOrInterruptTransfer.TransferFlags
> = direction | USBD_SHORT_TRANSFER_OK;
> (*urb)->UrbBulkOrInterruptTransfer.TransferBufferLength = size;
> (*urb)->UrbBulkOrInterruptTransfer.TransferBufferMDL = 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="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=iso-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,
> >
> > I am working in Javax.Usb and trying to implement it for windows using
> Libusb but some features are
> > missing from Libusb, I am working in the things that I can do but some
> others I can not.
> >
> > I need help in supporting "Short Packets" submission. All the changes
> will be in the file transfer.c .
> > If anyone can do that or help me, I will really appreciate that.
> >
> > Thanks
> >
> > Bye
> >
> > -----------------------------------------------------------------
> >
> ------------------------------------------------------------------------
> -
> > 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
> >
>
>
> _______________________________________________________________________
> Jetzt neu! Sch?tzen Sie Ihren PC mit McAfee und WEB.DE. 3 Monate
> kostenlos testen. http://www.pc-sicherheit.web.de/startseite/?mc=022220
>
>
>
>
> ------------------------------
>
> 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=iso-8859-15
>
>
> >
> >
> > Hello All!
> >
> > 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).
> >
> > 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.
> >
> > 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.
> >
> > 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
> for details.
>
> >
> > 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.
> >
> > 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.
>
> >
> > Thanks!
> >
> > Best regards,
> > Konstantin Klubnichkin
> > --
> > 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.
> >
> >
> >
> ------------------------------------------------------------------------
> -
> > 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
> >
>
>
> ________________________________________________________________________
> ______
> Jetzt neu! Im riesigen WEB.DE Club SmartDrive Dateien freigeben und mit
> Freunden teilen!
> http://www.freemail.web.de/club/smartdrive_ttc.htm/?mc=021134
>
>
>
>
> ------------------------------
>
> 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=iso-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,
> >
> > 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
> >
> > -----------------------------------------------------------------
> >
> ------------------------------------------------------------------------
> -
> > 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
> >
>
>
> _____________________________________________________________________
> Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
> http://smartsurfer.web.de/?mc=100071&distributionid=000000000066
>
>
>
>
> ------------------------------
>
> 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=iso-8859-15
>
>
> Thanks for the patch, Rob! I'll add this soon.
>
> Stephan
>
> >
> > >
> > > 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.
> > >
> > >
> > > static NTSTATUS create_urb(libusb_device_t *dev, URB **urb, int
> > > direction,
> > > int urb_function, int endpoint, int
> > > packet_size,
> > > MDL *buffer, int size)
> > > {
> > > USBD_PIPE_HANDLE pipe_handle = NULL;
> > > int num_packets = 0;
> > > int i, urb_size;
> > >
> > > *urb = 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 == URB_FUNCTION_ISOCH_TRANSFER)
> > > {
> > > if (packet_size <= 0)
> > > {
> > > DEBUG_ERROR("create_urb(): invalid packet size = %d",
> > > packet_size);
> > > return STATUS_INVALID_PARAMETER;
> > > }
> > >
> > > num_packets = (size + packet_size - 1) / packet_size;
> > >
> > > if (num_packets <= 0)
> > > {
> > > DEBUG_ERROR("create_urb(): invalid number of packets =
> %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 = sizeof(struct _URB_ISOCH_TRANSFER)
> > > + sizeof(USBD_ISO_PACKET_DESCRIPTOR) * num_packets;
> > > }
> > > else /* bulk or interrupt transfer */
> > > {
> > > urb_size = sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER);
> > > }
> > >
> > > *urb = 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 = (USHORT)urb_size;
> > > (*urb)->UrbHeader.Function = (USHORT)urb_function;
> > >
> > > /* isochronous transfer */
> > > if(urb_function == URB_FUNCTION_ISOCH_TRANSFER)
> > > {
> > > (*urb)->UrbIsochronousTransfer.PipeHandle = pipe_handle;
> > > (*urb)->UrbIsochronousTransfer.TransferFlags
> > > = direction | USBD_SHORT_TRANSFER_OK |
> > > USBD_START_ISO_TRANSFER_ASAP;
> > > (*urb)->UrbIsochronousTransfer.TransferBufferLength = size;
> > > (*urb)->UrbIsochronousTransfer.TransferBufferMDL = buffer;
> > > (*urb)->UrbIsochronousTransfer.NumberOfPackets = num_packets;
> > >
> > > for(i = 0; i < num_packets; i++)
> > > {
> > > (*urb)->UrbIsochronousTransfer.IsoPacket[i].Offset = i *
> > > packet_size;
> > > (*urb)->UrbIsochronousTransfer.IsoPacket[i].Length =
> > > packet_size;
> > > }
> > > }
> > > /* bulk or interrupt transfer */
> > > else
> > > {
> > > (*urb)->UrbBulkOrInterruptTransfer.PipeHandle = pipe_handle;
> > > (*urb)->UrbBulkOrInterruptTransfer.TransferFlags
> > > = direction | USBD_SHORT_TRANSFER_OK;
> > > (*urb)->UrbBulkOrInterruptTransfer.TransferBufferLength =
> size;
> > > (*urb)->UrbBulkOrInterruptTransfer.TransferBufferMDL = buffer;
> > > }
> > >
> > > return STATUS_SUCCESS;
> > > }
> > >
> > > 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, July 25, 2007 3:04 PM
> > > To: lib...@li...
> > > Subject: Libusb-win32-devel Digest, Vol 14, Issue 10
> > >
> > > 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. Not working, vista32 (Carl Kenner)
> > >
> > >
> > >
> ----------------------------------------------------------------------
> > >
> > > 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=ISO-8859-1; format=flowed
> > >
> > > 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).
> > >
> > > Uninstalling the filter driver makes it go back to normal.
> > >
> > > 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.
> > >
> > > 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.
> > >
> > > 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.
> > >
> > > 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?
> > >
> > >
> > >
> > > ------------------------------
> > >
> > >
> ------------------------------------------------------------------------
> > > -
> > > 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 14, Issue 10
> > > **************************************************
> > >
> > >
> >
> ************************************************************************
> ****************
> > >
> > > 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.
> > >
> > >
> >
> ************************************************************************
> ****************
> > >
> > >
> >
> ------------------------------------------------------------------------
> -
> > > 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
> >
> >
>
>
> _______________________________________________________________________
> Jetzt neu! Sch?tzen Sie Ihren PC mit McAfee und WEB.DE. 3 Monate
> kostenlos testen. http://www.pc-sicherheit.web.de/startseite/?mc=022220
>
>
>
>
> ------------------------------
>
> ------------------------------------------------------------------------
> -
> 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.
>
> ****************************************************************************************
>
> -------------------------------------------------------------------------
> 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
>
______________________________________________________________________________
Jetzt neu! Im riesigen WEB.DE Club SmartDrive Dateien freigeben und mit
Freunden teilen! http://www.freemail.web.de/club/smartdrive_ttc.htm/?mc=021134
|