Date: Fri, 21 Jul 2006 23:52:04 -0500 From: Robert Nilsson <robert@nilssonstudios.com> To: freebsd-usb@freebsd.org Subject: [PATCH] libusb usb_clear_halt implementation Message-ID: <61566738-B90E-4C80-B596-50912DC9872B@nilssonstudios.com>
next in thread | raw e-mail | index | archive | help
In order to get a device working correctly after a program restart I
had to use this function. It's a pretty simple change.
--- libusb-0.1.12/bsd.c Fri Mar 3 20:52:46 2006
+++ libusb-0.1.12.rob/bsd.c Fri Jul 21 22:47:55 2006
@@ -623,9 +623,21 @@
int usb_clear_halt(usb_dev_handle *dev, unsigned int ep)
{
- /* Not yet done, because I haven't needed it. */
+ int ret;
+ struct usb_ctl_request ctl_req;
- USB_ERROR_STR(-ENOSYS, "usb_clear_halt called, unimplemented on
BSD");
+ ctl_req.ucr_addr = 0; // Not used for this type of request
+ ctl_req.ucr_request.bmRequestType = UT_WRITE_ENDPOINT;
+ ctl_req.ucr_request.bRequest = UR_CLEAR_FEATURE;
+ USETW(ctl_req.ucr_request.wValue, UF_ENDPOINT_HALT);
+ USETW(ctl_req.ucr_request.wIndex, ep);
+ USETW(ctl_req.ucr_request.wLength, 0);
+ ctl_req.ucr_flags = 0;
+
+ if ((ret = ioctl(dev->fd, USB_DO_REQUEST, &ctl_req)) < 0)
+ USB_ERROR_STR(-errno, "clear_halt: failed for %d", ep);
+
+ return ret;
}
int usb_reset(usb_dev_handle *dev)
Rob.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?61566738-B90E-4C80-B596-50912DC9872B>
