From owner-freebsd-usb@FreeBSD.ORG Mon Sep 21 17:32:03 2009 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0D32B106566B for ; Mon, 21 Sep 2009 17:32:03 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe07.swip.net [212.247.154.193]) by mx1.freebsd.org (Postfix) with ESMTP id 58B0E8FC0A for ; Mon, 21 Sep 2009 17:32:01 +0000 (UTC) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.0 c=1 a=6U-Pe18MTAwA:10 a=MnI1ikcADjEx7bvsp0jZvQ==:17 a=MjWnJEQqbsKpB2t2Ec4A:9 a=c3_tBq54FzU5S8p38AAA:7 a=miSVSJ7hUBQieyiELOC7QWufVPsA:4 Received: from [188.126.201.140] (account mc467741@c2i.net HELO laptop.adsl.tele2.no) by mailfe07.swip.net (CommuniGate Pro SMTP 5.2.13) with ESMTPA id 1301258920; Mon, 21 Sep 2009 19:32:00 +0200 From: Hans Petter Selasky To: "Pierre-Luc Drouin" Date: Mon, 21 Sep 2009 19:32:35 +0200 User-Agent: KMail/1.11.4 (FreeBSD/9.0-CURRENT; KDE/4.2.4; i386; ; ) References: <4AB6DA79.7050209@pldrouin.net> <200909211827.53014.hselasky@c2i.net> <4AB7B7E6.9070005@pldrouin.net> In-Reply-To: <4AB7B7E6.9070005@pldrouin.net> X-Face: (%:6u[ldzJ`0qjD7sCkfdMmD*RxpOwEEQ+KWt[{J#x6ow~JO:,zwp.(t; @Aq :4:&nFCgDb8[3oIeTb^'",;u{5{}C9>"PuY\)!=#\u9SSM-nz8+SR~B\!qBv MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200909211932.37015.hselasky@c2i.net> Cc: ed@freebsd.org, freebsd-usb@freebsd.org Subject: Re: usb/138659: uftdi driver broken in RELENG_8/CURRENT 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: Mon, 21 Sep 2009 17:32:03 -0000 On Monday 21 September 2009 19:29:10 Pierre-Luc Drouin wrote: > Hans Petter Selasky wrote: > > On Monday 21 September 2009 03:44:25 Pierre-Luc Drouin wrote: > >> Hi, > >> > >> I am also having troubles with the uftdi driver on 8.0-BETA4. > >> I am trying to use a fan controller (mCubed bigNG) that uses a FT232BL > >> chip and it does not seem to be responding on FreeBSD 8.0 while the same > >> code works perfectly on Linux (I have not tried the code on RELENG_7 yet > >> but I could install it if necessary). > >> > >> Here is the very simple code I am using for testing: > >> #include > >> #include > >> #include > >> #include > >> #include > >> > >> int main(); > >> > >> #define DEV "/dev/ttyU0" > >> > >> #define TBAN_SER_SOURCE1 0x05 /* Primary source */ > >> #define TBAN_SER_SOURCE2 0x06 /* Alternative source (miniNG...) > >> */ > >> > >> #define TBAN_SER_REQUEST 0x36 > >> > >> int main() > >> { > >> int fd; > >> int result; > >> struct termios oldtio, newtio; > >> unsigned char buf[285]; > >> > >> printf("Opening device\n"); > >> fd=open(DEV, O_RDWR | O_NOCTTY); > >> > >> if(fd<0) { > >> perror(DEV); > >> return 1; > >> } > >> > >> result=tcgetattr(fd,&oldtio); > >> if(result<0) { > >> perror("tcgetattr"); > >> return 1; > >> } > >> > >> memcpy(&newtio,&oldtio,sizeof(struct termios)); > >> newtio.c_cflag = B19200 > >> > >> | CRTSCTS > >> | CS8 > >> | CREAD; > >> > >> newtio.c_iflag = IGNPAR; > >> newtio.c_oflag = 0; > >> newtio.c_lflag = 0; > >> newtio.c_cc[VMIN] = 1; > >> newtio.c_cc[VTIME] = 0; > >> > >> result=tcflush(fd, TCIFLUSH); > >> if(result<0) { > >> perror("tcflush"); > >> return 1; > >> } > >> > >> result=tcsetattr(fd,TCSANOW,&newtio); > >> if(result<0) { > >> perror("tcsetattr"); > >> return 1; > >> } > >> > >> sleep(1); > >> > >> printf("Performing initial query\n"); > >> buf[0]=TBAN_SER_SOURCE1; > >> buf[1]=TBAN_SER_REQUEST; > >> > >> printf("Requesting status\n"); > >> result=write(fd,buf,2); > >> if(result<0) { > >> perror("write"); > >> return 1; > >> } > >> > >> sleep(1); > >> > >> printf("Reading status\n"); > >> result=read(fd,buf,32); > >> if(result<0) { > >> perror("read"); > >> return 1; > >> } > >> > >> result=tcsetattr(fd,TCSANOW,&oldtio); > >> if(result<0) { > >> perror("tcsetattr"); > >> return 1; > >> } > >> > >> result=close(fd); > >> if(result<0) { > >> perror("close"); > >> return 1; > >> } > >> return 0; > >> } > >> > >> It hangs while reading independently of the number of bits I am reading. > >> > >> Here is the output from dmesg when I load the uftdi module: > >> Sep 20 21:31:31 ldaemon kernel: uftdi0: on usbus6 > >> Sep 20 21:31:31 ldaemon kernel: ucom_attach_tty:317: tp = > >> 0xffffff001f12b400, unit = 0 Sep 20 21:31:31 ldaemon kernel: > >> ucom_attach_tty:346: ttycreate: U0 Sep 20 21:31:34 ldaemon root: Unknown > >> USB device: vendor 0x051d product 0x0002 bus uhub0 > >> > >> Here is the output in /var/log/messages when I enable the debug output > >> for ucom and uftdi: Sep 20 21:33:30 ldaemon kernel: ucom_open:554: tp = > >> 0xffffff001f12b400 Sep 20 21:33:30 ldaemon kernel: ucom_dtr:827: onoff = > >> 1 Sep 20 21:33:30 ldaemon kernel: ucom_line_state:799: on=0x01, off=0x00 > >> Sep 20 21:33:30 ldaemon kernel: ucom_rts:838: onoff = 1 > >> Sep 20 21:33:30 ldaemon kernel: ucom_line_state:799: on=0x02, off=0x00 > >> Sep 20 21:33:30 ldaemon kernel: ucom_break:816: onoff = 0 > >> Sep 20 21:33:30 ldaemon kernel: ucom_line_state:799: on=0x00, off=0x04 > >> Sep 20 21:33:30 ldaemon kernel: ucom_status_change:901: > >> Sep 20 21:33:30 ldaemon kernel: ucom_param:950: sc = 0xffffff001f12ac58 > >> Sep 20 21:33:30 ldaemon kernel: uftdi_pre_param:653: > >> Sep 20 21:33:30 ldaemon kernel: ucom_dtr:827: onoff = 1 > >> Sep 20 21:33:30 ldaemon kernel: ucom_line_state:799: on=0x01, off=0x00 > >> Sep 20 21:33:30 ldaemon kernel: ucom_rts:838: onoff = 1 > >> Sep 20 21:33:30 ldaemon kernel: ucom_line_state:799: on=0x02, off=0x00 > >> Sep 20 21:33:30 ldaemon kernel: ucom_cfg_open:520: > >> Sep 20 21:33:30 ldaemon kernel: uftdi_cfg_open:354: > >> Sep 20 21:33:30 ldaemon kernel: uftdi_read_callback:459: status change > >> msr=0xf0 (0x00) lsr=0x60 (0x00) Sep 20 21:33:30 ldaemon kernel: > >> ucom_status_change:901: > >> Sep 20 21:33:30 ldaemon kernel: uftdi_cfg_get_status:705: msr=0xf0 > >> lsr=0x60 Sep 20 21:33:30 ldaemon kernel: ucom_cfg_status_change:887: DCD > >> changed to 1 Sep 20 21:33:30 ldaemon kernel: uftdi_cfg_param:672: > >> Sep 20 21:33:30 ldaemon kernel: ucom_ioctl:653: cmd = 0x402c7413 > >> Sep 20 21:33:30 ldaemon kernel: ucom_ioctl:653: cmd = 0x80047410 > >> Sep 20 21:33:30 ldaemon kernel: ucom_ioctl:653: cmd = 0x802c7414 > >> Sep 20 21:33:30 ldaemon kernel: ucom_param:950: sc = 0xffffff001f12ac58 > >> Sep 20 21:33:30 ldaemon kernel: uftdi_pre_param:653: > >> Sep 20 21:33:30 ldaemon kernel: uftdi_cfg_get_status:705: msr=0xf0 > >> lsr=0x60 Sep 20 21:33:30 ldaemon kernel: uftdi_cfg_param:672: > >> Sep 20 21:33:30 ldaemon kernel: ucom_get_data:1064: cnt=0 > >> Sep 20 21:33:31 ldaemon kernel: ucom_ioctl:653: cmd = 0x80047410 > >> Sep 20 21:33:32 ldaemon kernel: ucom_outwakeup:1009: sc = > >> 0xffffff001f12ac58 Sep 20 21:33:32 ldaemon kernel: ucom_get_data:1064: > >> cnt=2 > >> Sep 20 21:33:32 ldaemon kernel: ucom_get_data:1064: cnt=0 > >> > >> I really need to get this working so I am ready to test things as much > >> as I can... > > > > Hi, > > > > You need to set raw mode for the TTY device I think. Maybe Ed can give > > you the function name you need to call to do that? > > > > --HPS > > Do I need to do something like that? > ioctl(fileno(stdin), TIOCGETP, &tty_org); > tty = tty_org; > > /* set terminal to raw mode ... */ > tty.sg_flags |= CRMOD; > tty.sg_flags &= ~ECHO; > tty.sg_flags &= ~XTABS; > tty.sg_flags |= RAW; > > Thanks! > Pierre-Luc Drouin Hi, You need to call this function: void cfmakeraw(struct termios *t); --HPS