Please login or register.

Login with username, password and session length
Advanced search  


Visit our home page for VL info. For support and documentation, visit the Vector Linux Knowledge Center or search the Knowledge Center and this Forum using the search box above.

Author Topic: USB programming: ioctl connect call has random delays  (Read 38 times)


  • Member
  • *
  • Posts: 85
USB programming: ioctl connect call has random delays
« on: October 19, 2016, 11:13:52 am »

VL Version: VL64-7.1 Standard
Kernel: 3.8.16 #2

Preface: I've been poking around the internet looking for more information on ioctl connect delays but haven't really found much.  Any suggestions or feedback appreciated.

I have a C program that calibrates joysticks using ioctl calls.  The code in question looks like below:

Code: [Select]
usb_ioctl.ioctl_code = USBDEVFS_DISCONNECT;
ioctl(fd, USBDEVFS_IOCTL, &usb_ioctl);

usb_ioctl.ioctl_code = USBDEVFS_CONNECT;
ioctl(fd, USBDEVFS_IOCTL, &usb_ioctl);

The 2nd ioctl call with USBDEVFS_CONNECT is the culprit.  I'd say 90% of the time, this call takes about 5ms.  The other 10% of the calls can take anywhere up to 10 seconds.  The delay time is random, so sometimes it is less.

What I have tried so far is to put the calibrator in a loop and force it to retry if execution time goes past 50ms.  So far this doesn't seem to help, as the newly spawn calibrators just keep delaying as well.

I have some code to manually reset the USB ports (to simulate a physical reconnect) but haven't tried it out yet.  I was trying to avoid the resetting of ports just in case that leads to other problems.  Other than these random delays in the ioctl call, I haven't experienced any other hardware related problems.

Any info or help on debugging the problem or fixing it would be great.  Thanks!
« Last Edit: October 19, 2016, 11:18:45 am by Rytz »
~ Rytz