From owner-freebsd-drivers@FreeBSD.ORG Fri Jun 17 09:39:24 2011 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E7239106566B for ; Fri, 17 Jun 2011 09:39:23 +0000 (UTC) (envelope-from orca@tdlsoftware.org) Received: from server2.hostultra.com (server2.hostultra.com [178.63.65.195]) by mx1.freebsd.org (Postfix) with ESMTP id 5C5F58FC18 for ; Fri, 17 Jun 2011 09:39:23 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=tdlsoftware.org) by server2.hostultra.com with esmtpa (Exim 4.72 (FreeBSD)) (envelope-from ) id 1QXV7b-0009Gg-0t for freebsd-drivers@freebsd.org; Fri, 17 Jun 2011 09:13:47 +0000 Received: from 91.195.58.188 ([91.195.58.188]) (SquirrelMail authenticated user orca@tdlsoftware.org) by tdlsoftware.org with HTTP; Fri, 17 Jun 2011 11:13:47 +0200 Message-ID: <7042daa3e72e642db80c0622cc9acf67.squirrel@tdlsoftware.org> Date: Fri, 17 Jun 2011 11:13:47 +0200 From: "Peter Laursen" To: freebsd-drivers@freebsd.org User-Agent: SquirrelMail/1.4.20 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server2.hostultra.com X-AntiAbuse: Original Domain - freebsd.org X-AntiAbuse: Originator/Caller UID/GID - [26 6] / [26 6] X-AntiAbuse: Sender Address Domain - tdlsoftware.org X-Source: X-Source-Args: X-Source-Dir: Subject: Confused about USB HID devices X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2011 09:39:24 -0000 Hi everyone, I am trying to write a device driver for a USB HID device. The device in question is a Braille display (electronic equipment that transforms letters into braille dots for blind people to read). Potentially, this driver may be the stepping stone for expanding our installer so that blind people may be able to install FreeBSD without sighted assistance. My problem is that, seemingly no matter what I do, I cannot get my braille display to show any output if I go through my device driver. If I send output from a test program written with the aid of libusb, the display shows everything correctly, but when I send the same data from my test device driver, I get an error code of 22. When I send the following data packet from my libusb program, I see the word "Hello": (Every value is in decimal. The first three bytes is HID output report byte for this device, next byte is offset on the display and the third is the length of the data to be shown on the display) "2 0 40 83 17 7 7 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0" When I try to send the same data packet from within my device driver, I get an error code with the value 22. I insert my USB callback function below: static void alva_write_callback(struct usb_xfer* xfer, usb_error_t err) { struct alva_softc* sc = usbd_xfer_softc(xfer); struct usb_device_request req; req.bmRequestType = UT_WRITE_CLASS_INTERFACE; req.bRequest=UR_SET_REPORT; USETW2(req.wValue, UHID_OUTPUT_REPORT, 2); req.wIndex[0]=1; req.wIndex[1]=0; USETW(req.wLength, 43); mtx_lock(&sc->mtx); switch (USB_GET_STATE(xfer)) { case USB_ST_SETUP: printf("Inside USB write setup state.\n"); usbd_xfer_set_frame_data(xfer,0,&req,8); unsigned char Packet[43] = {0}; Packet[0]=2; Packet[1]=0; Packet[2]=40; Packet[3] = 83; Packet[4] = 17; Packet[5] = 7; Packet[6] = 7; Packet[8] = 21; for (int i = 9; i < 43; i++) Packet[i]=0; usbd_xfer_set_frame_data(xfer,1,Packet,43); usbd_transfer_submit(xfer); break; case USB_ST_TRANSFERRED: printf("Reached the transferred state.\n"); break; default: printf("An error must have occurred. Error code: %d\n", err); usbd_transfer_clear_stall(xfer); break; } mtx_unlock(&sc->mtx); } I am quite out of ideas as to how I might solve the problem. I will gladly provide any additional information, but I'm quite new to writing device drivers, so please bear with me if I have missed anything obvious or missed out important information. I have looked through the USB HID driver,read the HID specification and googled and nothing has given me any clues. I hope someone out here can help guide me in the right direction. All the best, Peter. FreeBSD 8.2-i386