From owner-freebsd-usb@FreeBSD.ORG Thu Apr 12 06:59:07 2007 Return-Path: X-Original-To: freebsd-usb@freebsd.org Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A01C716A404 for ; Thu, 12 Apr 2007 06:59:07 +0000 (UTC) (envelope-from z3tbl4@gmail.com) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.183]) by mx1.freebsd.org (Postfix) with ESMTP id 66E0713C465 for ; Thu, 12 Apr 2007 06:59:07 +0000 (UTC) (envelope-from z3tbl4@gmail.com) Received: by py-out-1112.google.com with SMTP id f31so366812pyh for ; Wed, 11 Apr 2007 23:59:06 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=ROW5R4/s77Bx+ELa0G+I4Fxyr3GifBv/DJy/6Kjdk1TzNhfmUyAMm7pQhsEwvFoOD4nL75t7kyyZ6yxc/yTd+9LZFVoiMKBEWPhBuS+ECd0L/n09ZR02AZwTjM5Nyu2Wjw3Kmtn0IZbXUDTUZHjFpCG6owrtCA6hFzdeyVEzM04= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=PHD5BzTPvbbSD3euf38CRoeFkrpTSkk92Luci53wHfRNyQt2LcUF7+8T8vxL9DvHNZRhEcoQ9xqmoRqguiggC/twIJfa6yMVx/T0Zw31zXYRvkfdxuqKZMvUlW/LGzaKlNn8C5MYdiUYXJcO0GY4GG1+xBFZmGMVdxtgE709q9Q= Received: by 10.35.96.7 with SMTP id y7mr2585767pyl.1176359394871; Wed, 11 Apr 2007 23:29:54 -0700 (PDT) Received: by 10.35.26.20 with HTTP; Wed, 11 Apr 2007 23:29:54 -0700 (PDT) Message-ID: <437e81e00704112329h634c0b22y782f32214054b4f@mail.gmail.com> Date: Thu, 12 Apr 2007 10:29:54 +0400 From: "Z3tbl4 []" To: freebsd-usb@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: FBSD 6.0 UGEN X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Apr 2007 06:59:07 -0000 Greetings everyone! Could someone ,please, advice me a solution to solve such problem- i have an usb device, which is present in my FBSD 6.0 as /dev/ugen0 and /dev/ugen0.1 i need to send to this device 5 bytes and read from it 3 bytes but i'm not good in usb protocol and i don't get a right result . here is my test code in C. Thank you. #include #include #include #include #include #include #include #include #include #include #include #define RBUF 3 #define WBUF 5 char *pidfile = "/var/run/pgs.pid"; char *u = 0; /* device file */ unsigned char txb[WBUF] = {0x06, 0x00, 0x00, 0x00, 0x00}; unsigned char rxb[RBUF]; unsigned char *ufd_dat; extern char *optarg; int i = 0, n , c, ret; int fd , fp; unsigned char rbuf[RBUF], wbuf[WBUF] = {0x06, 0x00, 0x00, 0x00, 0x00}; open_devs(void) { if ((fd = open(u, O_RDWR)) < 0) err(1, "cannot open %s", u); }; close_devs(void) { close(fd); }; save_pid() { fp = fopen(pidfile, "w"); if (fp != 0) { fprintf(fp, "%d\n", getpid()); fclose(fp); }; }; int main(int argc, char *argv[]) { while ((c = getopt(argc, argv, ":?hd:i:")) != -1) { switch (c) { case 'd': u = optarg; printf("Input device set to %s\n", optarg); break; case 'i': pidfile = optarg; printf("Using pid file %s\n", optarg); break; case ':': case '?': case 'h': default: break; } } if (argc < 1) { printf("Wrong number of options!\n\n"); }; save_pid(); open_devs(); ////////////////////////GET_DEVICEINFO ////////////////////////// struct usb_device_info di; ret = ioctl(fd, USB_GET_DEVICEINFO, &di); printf("ret=%d\n", ret); printf("product %s\n", di.udi_product); printf("vendor %s\n", di.udi_vendor); printf("release %s\n", di.udi_release); printf("devnames %s\n", di.udi_devnames); printf("ports %02X\n", di.udi_ports); printf("address %02X\n", di.udi_addr); //////////////////////////////////////////////////////////////// //////////////////////USB_GET_DEVICE_DESC ////////////////////// usb_device_descriptor_t udd; if (ioctl(fd, USB_GET_DEVICE_DESC, &udd) == -1) { err(2, "%s", u); } printf("idVendor=%02X\n", UGETW(udd.idVendor)); printf("idProduct=%02X\n", UGETW(udd.idProduct)); //////////////////////////////////////////////////////////////// //////////////////////WRITE WBUF //////////////////////////////// struct usb_ctl_request dr; dr.ucr_addr = di.udi_addr; dr.ucr_data = txb; dr.ucr_request.bmRequestType = UT_WRITE_VENDOR_ENDPOINT; dr.ucr_request.bRequest = 0; USETW(dr.ucr_request.wValue, 0); USETW(dr.ucr_request.wIndex, 0); USETW(dr.ucr_request.wLength, WBUF); if (ioctl(fd, USB_DO_REQUEST, &dr) == 0) printf("write successfull!\n"); else printf("Write FAILED!\n"); printf("%2X %2X %2X %2X %2X\n", txb[0], txb[1], txb[2], txb[3], txb[4]); /////////////////////////////////////////////////////////////// /////////////////////READ RBUF ///////////////////////////////// struct usb_ctl_request rdr; rdr.ucr_addr = di.udi_addr; rdr.ucr_data = rxb; rdr.ucr_request.bmRequestType = UT_READ_VENDOR_ENDPOINT; rdr.ucr_request.bRequest = 0; USETW(rdr.ucr_request.wValue, 0); USETW(rdr.ucr_request.wIndex, 0); USETW(rdr.ucr_request.wLength, 0); if (ioctl(fd, USB_DO_REQUEST, &rdr) != 0) printf("READ FAILED!\n"); else printf("READ: %2X %2X %2X\n", rxb[0], rxb[1], rxb[2]); /////////////////////////////////////////////////////////////// close_devs(); exit(0); } ./Ugen_test -d /dev/ugen0 Input device set to /dev/ugen0 ret=0 product SOBAKA 2.2 ( WDT + DS + Amp ) vendor PGS release 0.02 devnames ugen0 ports BFBFEA84 address 02 idVendor=777 idProduct=FF77 write successfull! 6 0 0 0 0 READ: 0 0 0