gallegretto | 30 Jun 20:51 2015

Callback timing issue BULK TRANSFERS

 Hi, I have an issue I can't explain.

I submit two bulk transfers:

   1. transfer OUT
   2. transfer IN

Tranafer IN is submitted only when transfer OUT is submitted successfully.

Sometimes I enter in the callback of the transfer OUT after the callback of
the transfer-IN....  
They have same buffer size.

I am sending 1. and 2. continuously and I have this issue only with the
first two transfers.

If somebody can help thanks

--
View this message in context: http://libusb.6.n5.nabble.com/Callback-timing-issue-BULK-TRANSFERS-tp5714839.html
Sent from the LibUSB Dev - Win32 mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
Chris E | 6 Jun 08:42 2015
Picon

Simple iso code isn't sending any data at all (not even a request)?

Basically just using a slightly altered version of the example iso code to try and communicate to a USB device I'm making.  It works absolutely fine when I send a control tranfsfer.

However, when I try an iso transfer it fails.  Firstly, the pipe doesn't reset (returns error 57h), and then the wait ans release fails (returns error 490h).  Absolutely nothing, IN or OUT, is visible in the packet sniffer (USBPcap).

To be honest, I don't fully understand why this is the case and have almost zero experience programming with Windows (or any OS at all - I'm an electrical engineer and most of the stuff I do is "barebones" programming on FPGAs or microcontrollers).

Attempt to reset the pipe is done through UsbK_ResetPipe(handle, pipeID);
Reading the iso pipe is attempted through UsbK_IsoReadPipe(handle, pipeID, isoBuffer, sizeof(isoBuffer), ovlkHandle, isoCtx);
In both occasions, I can't see why any input would be considered dodgy.  The handle works fine for control transfers and the pipeID is checked by Usb.QueryPipe.

Is this a simple noob mistake or something more serious?

Thanks,
~Chris

P.S. Yes, the application requires that I use iso.  It's a USB oscilloscope!

Full output from CMD is:
Looking for device vid/pid 03EB/A000.. 
Using 03EB:A000 (5&15D9C317&0&4): USBGobindar Dummy Device - Atmel Corp. 
Device opened successfully! 
Pipe Information: 
  PipeId=0x81 PipeType=0x01 Interval=1 MaximumPacketSize=256 
READING ISO PACKET 
&ovlPool= 1702336 
&ovlkHandle= 1702348 
UsbK_ResetPipe failed. ErrorCode: 00000057h 
IsoReadPipe failed. ErrorCode: 00000490h 









Full code is:
#include "examples.h"
#include <string.h>

#define mode 1  //0 for control test, 1 for iso test
#define ISO_PACKETS_TO_READ 4
#define ISO_PACKET_SIZE 256

KUSB_DRIVER_API Usb;

DWORD __cdecl main(int argc, char* argv[])
{
KLST_HANDLE deviceList = NULL;
KLST_DEVINFO_HANDLE deviceInfo = NULL;
KUSB_HANDLE handle = NULL;
DWORD ec = ERROR_SUCCESS;
UCHAR pipeIndex = 0;
WINUSB_PIPE_INFORMATION pipeInfo;
WINUSB_SETUP_PACKET setupPacket;

//ISO only
PKISO_CONTEXT isoCtx = NULL;
KOVL_HANDLE ovlkHandle = NULL;
KOVL_POOL_HANDLE ovlPool = NULL;
unsigned char isoBuffer[32 * 256];
BOOL success;
UCHAR pipeID = 0x81;
ULONG transferred = 0;
DWORD errorCode = ERROR_SUCCESS;



BOOL controlSuccess;
unsigned char controlBuffer[64];
UINT bytesTransferred = 0;
ULONG VIDin, PIDin;
int command;
ULONG deviceCount = 0;

//Read in parameters from CMD
strcpy(controlBuffer, argv[1]);
sscanf(argv[2], "%d", &command);
sscanf(argv[3], "%4x", &VIDin);
sscanf(argv[4], "%04x", &PIDin);

//Commands to send to device
switch (command){
case 1:  //Print to LCD
setupPacket.RequestType = 0x40;
setupPacket.Request = 0xa0;
setupPacket.Value = 0x00;
setupPacket.Index = 0x00;
setupPacket.Length = 64;
break;
case 2: //Backlight off
setupPacket.RequestType = 0x40;
setupPacket.Request = 0xa1;
setupPacket.Value = 0x00;
setupPacket.Index = 0x00;
setupPacket.Length = 0;
break;
case 3:  //Backlight on
setupPacket.RequestType = 0x40;
setupPacket.Request = 0xa1;
setupPacket.Value = 0x01;
setupPacket.Index = 0x00;
setupPacket.Length = 0;
break;
default:
printf("Yeah Nah");
goto Done;
}


//Init device list!
if (!LstK_Init(&deviceList, 0)) {
printf("Error initializing device list.\n");
return 0;
}

//Check if device list is empty
LstK_Count(deviceList, &deviceCount);
if (!deviceCount) {
printf("Device list empty.\n");
LstK_Free(deviceList); // If LstK_Init returns TRUE, the list must be freed.
return 0;
}

printf("Looking for device vid/pid %04X/%04X..\n", VIDin, PIDin);

//Set device info to the info specified by the INF that belongs to said VID/PID pair
LstK_FindByVidPid(deviceList, VIDin, PIDin, &deviceInfo);
if (deviceInfo){
printf("Using %04X:%04X (%s): %s - %s\n",
deviceInfo->Common.Vid,
deviceInfo->Common.Pid,
deviceInfo->Common.InstanceID,
deviceInfo->DeviceDesc,
deviceInfo->Mfg);
}
else printf("Yeah nah kent couldn't find the device aye\n");

//Tell LibusbK to intercept everything related to this device
LibK_LoadDriverAPI(&Usb, deviceInfo->DriverID);

// Initialize the device
if (!Usb.Init(&handle, deviceInfo)){
ec = GetLastError();
printf("Usb.Init failed. ErrorCode: %08Xh\n", ec);
goto Done;
}
printf("Device opened successfully!\n");

// while the device is opened, query information on the endpoints
// of the first alternate setting of the current interface.
printf("Pipe Information:\n");
while (Usb.QueryPipe(handle, 0, pipeIndex++, &pipeInfo)){
printf("  PipeId=0x%02X PipeType=0x%02X Interval=%u MaximumPacketSize=%u\n",
      pipeInfo.PipeId, pipeInfo.PipeType, pipeInfo.Interval, pipeInfo.MaximumPacketSize);
}

#if mode == 0
//Send Control Packet
printf("SENDING CONTROL PACKET\n");
controlSuccess = Usb.ControlTransfer(handle, setupPacket, controlBuffer, setupPacket.Length, &bytesTransferred, NULL);
if (controlSuccess) printf("%d BYTES TRANSFERRED", bytesTransferred);
else printf("ERROR");
#elif mode == 1 
printf("READING ISO PACKET\n");
//Define Iso Context
IsoK_Init(&isoCtx, ISO_PACKETS_TO_READ, 0);
IsoK_SetPackets(isoCtx, ISO_PACKET_SIZE);

//What is this overlapped pool?  Virtual Addresses for I/O?  Black magic?  The source of my errors.
OvlK_Init(&ovlPool, handle, 4, 0);
printf("&ovlPool= %d\n", &ovlPool);
OvlK_Acquire(&ovlkHandle, ovlPool);
printf("&ovlkHandle= %d\n", &ovlkHandle);

//Reset Pipe fails!
success = UsbK_ResetPipe(handle, pipeID);
if (~success){
errorCode = GetLastError();
printf("UsbK_ResetPipe failed. ErrorCode: %08Xh\n", errorCode);
}

//Set up iso pipe for n reads.
UsbK_IsoReadPipe(handle, pipeID, isoBuffer, sizeof(isoBuffer), ovlkHandle, isoCtx);
//Wait for it all to finish!
success = OvlK_WaitAndRelease(ovlkHandle, 1000, &transferred);
if (!success) {
errorCode = GetLastError();
printf("IsoReadPipe failed. ErrorCode: %08Xh\n", errorCode);
goto Done;
}
#endif



Done:
// Close the device handle
// if handle is invalid (NULL), has no effect
Usb.Free(handle);

// Free the device list
// if deviceList is invalid (NULL), has no effect
LstK_Free(deviceList);

// Free the iso context.
IsoK_Free(isoCtx);

// Free the overlapped pool.
OvlK_Free(ovlPool);

return ec;
}
------------------------------------------------------------------------------
_______________________________________________
Libusb-win32-devel mailing list
Libusb-win32-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Xiaofan Chen | 1 May 11:10 2015
Picon

Fwd: Main outstanding Windows backend patches

Not so sure if anyone here is interested in the following
work for libusb Windows backend. I myself can help on
the testing but I do not know much about programming
and will not be able to review the patches.

It will also be good that someone can work on to help
to improve the integration of libusb0.sys support under
libusb Windows backend. Right now it is not really usable.

Regards,
Xiaofan

---------- Forwarded message ----------
From: Xiaofan Chen <xiaofanc <at> gmail.com>
Date: Fri, May 1, 2015 at 5:08 PM
Subject: Main outstanding Windows backend patches
To: "libusb-devel <at> lists.sourceforge.net" <libusb-devel <at> lists.sourceforge.net>

There are a few major outstanding Windows backend patch series.
1. Hotplug
2. Isochronous transfer for libusbK (not yet WinUSB under Windows 8.1)
3. UsbDk backend

Hopefully someone will step in and work on the integration. Pete
mentioned that he would not have much time on libusb.

--
Xiaofan

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
Isaac Abbott | 30 Apr 15:28 2015

WinUSB WCID driver automatically installs but libusbK does not see the device

After following the steps outlined by Pete Patard here (https://github.com/pbatard/libwdi/wiki/WCID-Devices), my device successfully enumerates as a “WinUSB Generic Device” on my Windows 7 Pro x64 system. Unfortunately LstK_Init in lisbusbK no longer finds the device. It works correctly when I use Zadig to install the driver (non-WCID).
 
I did not implement the Device Interface GUID descriptor, is this necessary?
 
~Isaac
 
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Libusb-win32-devel mailing list
Libusb-win32-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Pradeepa Senanayake | 24 Apr 13:06 2015
Picon

LibusbK debug messages

Hello,

I have been using the libusbK library for more than one year for one of the projects I am involved in. It works very well. Recently I have encountered an issue in one of the devices. I still could not find the origin of the issue. 

I have access to the low level device firmware and the application which communicates with it. We decided to go with libusbK as the USB driver for the devices.

Basically what should happen is when we switch on the device it should ideally enumerate three USB devices in the device manager. This is not a composite USB device. But a device which has three separate child devices connected to an internal hub. First it enumerates as bootloader devices and when the PC application sends it the relevant data it will switch to the firmware. . 

Sometimes I can see that one of these three deivce does not get enumerated properly. It gives a code10 error in device manager. I think it comes when DeviceEntry fails in the driver code. May be the firmware is not responding to a standard query properly.

I would like to know to which query it is not responding properly. I was wandering whether there is any method to enable some sort of debug messages in the libusbK. What are the debugging options available in the library? I basically would like to see where the driver fails to enumerate the device. 

Since this is not always happening I am still unsure where the issue is.

Best Regards,
Pradeepa Senanayake.
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Libusb-win32-devel mailing list
Libusb-win32-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Simon Thiebaut | 23 Apr 09:00 2015
Picon

WinUSB Microsoft OS descriptors

Hi,

Please forgive me if this has already been answered, but I was not able to fin any related topic inside the previous posts.

I'm writing an application for monitoring sensor data through a USB link.
I can modify both the PC application (USB host) and the acquisition board firmware(USB device).

The PC app USB part is written with libusb, as the app is intended to be cross platform, though it is first developed under Windows.
The first version of the board firmware implements the HID class, but this is too limitating for the requirements of the app, and I want to change the class.

Therefore I was looking for a generic USB device driver that would automatically loads when the device is plugged in.
I have to do a choice between WinUSB or libusbK drivers.

After a few researches on WinUSB, I found this:
https://msdn.microsoft.com/en-us/library/windows/hardware/hh450799%28v=vs.85%29.aspx

That states that a WinUSB generic device must have in its firmware specific Microsoft OS Descriptors to work.

My question is: does libusbK have such requirements ? Will I have to add specific descriptors to make my device work ? Or nothing special is required (other than configuring properly the existing common descriptors) ?
The point is I do not wish to embed useless and not generic code in the firmware if there a is generic enough PC driver (for the Windows portage)...


Thank you very much for your answers.

Have a nice day,



Simon THIEBAUT

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Libusb-win32-devel mailing list
Libusb-win32-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Xiaofan Chen | 16 Apr 08:25 2015
Picon

Re: Iso ep Issue : win xp on virtualbox4.2 in ubuntu-14.04-x64, iso endpoint receive error frames.

On Wed, Apr 15, 2015 at 3:00 PM, linucos <8967983 <at> qq.com> wrote:
> hi, there
>      A strange issue with libusbk: not all frames are error, only some
> frames is error.
>      Logs like:
>      "ISO StartFrame=0009771Ah NumberOfPackets=64 ErrorCount=7
> Transferred=969
> ISO StartFrame=0009775Ah NumberOfPackets=64 ErrorCount=7 Transferred=969
> ISO StartFrame=0009779Ah NumberOfPackets=64 ErrorCount=8 Transferred=952
> ISO StartFrame=000977DAh NumberOfPackets=64 ErrorCount=7 Transferred=969
> ISO StartFrame=0009781Ah NumberOfPackets=64 ErrorCount=7 Transferred=969
> ISO StartFrame=0009785Ah NumberOfPackets=64 ErrorCount=4 Transferred=1020
> ISO StartFrame=0009789Ah NumberOfPackets=64 ErrorCount=5 Transferred=1003
> ISO StartFrame=000978DAh NumberOfPackets=64 ErrorCount=6 Transferred=986"
>    .
>    Other endpoints work well.
>
>    Thans for any idea.
>    By the way, same xp iso, same application, same driver, not work on
> VMWare.

Could you test on a real PC and not virtual machine? If the problem
does not exist on a real PC, I will think it is a problem with the
Virtual Machine's simulated USB driver stack.

--

-- 
Xiaofan

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF

Best round trip time possible over USB

Hi ,
 
We are developing a USB device for Windows PC and Libusb is considered device access.
 
Need to do some benchmarking tests to check the performance of this complete solution.
In this regard, We has a test app ( C++ console app) which writes 50 bytes of data using Libusb API and on device side once this data is simply looped back to PC.  When the round trip time from Transmit to receives is measured it is around 400 microseconds.
 
THE DEVICE IS A HIGH SPEED DEVICE and END POINTS ARE BULK MODE. NO OTHER USB DEVICE IS CONNECTED TO PC.
 
Is this the best performance possible for ?
 
Thanks
srinivas
 
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Libusb-win32-devel mailing list
Libusb-win32-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Alexander Stohr | 16 Mar 10:48 2015
Picon
Picon

add device port number, usb_device

refering to this old topic: https://sourceforge.net/p/libusb-win32/mailman/libusb-win32-devel/thread/20121212191459.GL24678 <at> trikaliotis.net/
 
the creator of the topic wrote:
> If I could translate a libusb0 symbolic index path to an interface’s DevicePath > (i.e. SP_DEVICE_INTERFACE_DETAIL.DevicePath, ex. > \\?\usb#vid_[VID]&pid_[PID]#[serialNumber]#{[GUID]}), > then I could use the DevicePath to get its SPDRP_ADDRESS property > (which is the port number).
a participant responded:
 
> BTW, take note the format of DevicePath is not fixed since some USB device may not have a serial number.
 
in fact the Windows OS demands that the DevicePath is unique.
in case there is no serial number then the OS decides to use the (still unique but not "moveable") connetor path.
this path is dependent on the topology and can for USB devices include the hub and port numbers plus a bit more.
 
if looking to the dumps from a later on added posting in that thread then you will see a real world example: C:\libusbK-dev-kit>klist Loading USB ID's maintained by Stephen J. Gowdy <linux.usb.ids <at> ...>.. 1. STMicroelectronics STLink dongle (SGS Thomson Microelectronics) [Connected] Service : libusb0 ClassGUID : {EB781AAF-9C70-4523-A5DF-642A87ECA567} DeviceID : USB\VID_0483&PID_3748\8&23117AA8&0&1 DeviceInterfaceGUID : {47C9C148-9738-1A9B-2CB6-86C13FA48892} SymbolicLink : \\?\usb#vid_0483&pid_3748#8&23117aa8&0&1#{47c9c148-97 38-1a9b-2cb6-86c13fa48892} DevicePath : \\.\libusb0-0001 SerialNumber : 8&23117AA8&0&1 BusNumber : 0 DeviceAddress : 1
as you can see the serial number is not really something a USB device would typically export
(probably it's device stored and provided string constant is just an empty property)
but it is rather a concataneted sequence of hub and port numbers.

conclusion: there is (in theory) always a string that forms a valid (and hopefully unique) serial number.
the contents of the OS used serial number entry is never empty/missing even if the low-level physical device layer does not provide one.

BTW there are some USB-JTAG debugger devices from a certain vendor around that all have the same serial.
with this setup at least the Windows OS will only allow to access one of these devices at a certain time.
it can be guessed that the vendor wanted this unit to be for some single-target demo use only. (and production might be a bit cheaper...)
the professional fully featured debuggers for that vendor can be optained from third parties at a noticeably higher price.
(the sales volum is low compared to the numbers of units on consumer markets.)
 
-Alex.
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Libusb-win32-devel mailing list
Libusb-win32-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Marcel Houben | 10 Feb 14:57 2015
Picon

Bulk stream: reading old data

Dear Sir/Madam,

 

I am using LibUsbK to read chunks of Bulk stream data (not all data is supposed to be read), sent from a USB 3.0 device. The USB device obtains and passes live data to the PC at 10 MHz, without caching/buffering.

Program works as follows:

1)      Initialize USB

2)      Clear pipe

3)      Get overlap

4)      Read variable amount of data (in KB)

5)      Wait and release

6)      Process

7)      Optional restart for new data, from step 2) onwards

 

During testing with this program I encountered an issue whereby old data is obtained for the first ~64 KB of every read. Only after reading more than 64 KB the actual live data is obtained. I made a workaround by obtaining 64 KB + requested amount data and removing the first 64 KB, but I am looking for a better solution. Physically disconnecting and reconnecting the device clears this buffer (while the device remains powered and the program is still active).

 

Could anyone shed some light on this issue? Is there perhaps some kind of buffering going on in the driver? Can this buffer be cleared before the read?

 

Best regards,

 

Marcel


The information sent with this e-mail is exclusively intended for the addressee.
If anyone has received this e-mail in error, the receiver is requested to indicate this to the sender and to destroy the e-mail completely without taking notice of the contents in any way or saving it.
Publication, copying, distribution and/or disclosure of the contents to third parties are not permitted.
NTS-Group is not liable for the correct and complete dispatch of the contents, nor for the prompt receipt of this e-mail.
If this e-mail contains so-called computer viruses, NTS-Group is not liable for any damage occurring as a consequence.
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Libusb-win32-devel mailing list
Libusb-win32-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
hustxyj | 28 Jan 13:22 2015

Re: A bug with libusb0

>> In file ioctl.c, function dispatch_ioctl, case LIBUSB_IOCTL_CONTROL_WRITE:
>> It's possible for transfer_buffer_mdl to be NULL. So the check is
>> unnecessary.

>Why do you think transfer_buffer_mdl can be NULL ?

I met a device which send a control packet without data.

Yongjian Xu
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/

Gmane