From owner-freebsd-usb@FreeBSD.ORG Sun Sep 20 20:42:20 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 A5DA2106566C for ; Sun, 20 Sep 2009 20:42:20 +0000 (UTC) (envelope-from pldrouin@pldrouin.net) Received: from smtp.cyberfingers.net (smtp.cyberfingers.net [198.177.254.227]) by mx1.freebsd.org (Postfix) with ESMTP id 83FA68FC0A for ; Sun, 20 Sep 2009 20:42:20 +0000 (UTC) Received: from mdaemon.pldrouin.net (CPE0023695b905f-CM001a666aca96.cpe.net.cable.rogers.com [99.246.67.95]) by smtp.cyberfingers.net (Postfix) with ESMTP id 2A439AB6C6F for ; Sun, 20 Sep 2009 16:22:45 -0400 (EDT) Message-ID: <4AB68F11.2080202@pldrouin.net> Date: Sun, 20 Sep 2009 16:22:41 -0400 From: Pierre-Luc Drouin User-Agent: Thunderbird 2.0.0.23 (X11/20090824) MIME-Version: 1.0 To: freebsd-usb@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Are asynchronous transfers supported by uftdi? 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: Sun, 20 Sep 2009 20:42:20 -0000 Hi, Are asynchronous transfers supported by uftdi? I am trying to modify a linux tool (tbancontrol) to control a fan controller on FreeBSD and SIGIO behaviour seems to be a bit random on FreeBSD compared to linux. Here are the main lines of the tool related to initialization: tban->port = open("/dev/ttyU0", O_RDWR | O_NOCTTY | O_NONBLOCK); ... saio.sa_handler = tban_signal_handler_IO; result = sigemptyset(&saio.sa_mask); saio.sa_flags = 0; result = sigaction(SIGIO, &saio, NULL); result = fcntl(tban->port, F_SETFL, FASYNC); ... tcgetattr(tban->port, &(tban->oldtio)); ... memcpy(&newtio,&tban->oldtio,sizeof(struct termios)); /*I added this line to avoid the error EINVAL when calling tcsetattr below. This is probably not enough to set all flags properly :S */ ... newtio.c_cflag = intToBaud(tban->baudrate) /*baudrate is 19200*/ | CRTSCTS | intToDataBits(tban->databits) /*databits is 8*/ | intToStopBits(tban->stopBits) /*stopBits is 0*/ | CLOCAL | CREAD; newtio.c_iflag = IGNPAR; newtio.c_oflag = 0; newtio.c_lflag = 0; newtio.c_cc[VMIN] = 1; newtio.c_cc[VTIME] = 0; ... result = tcsetattr(tban->port, TCSANOW, &newtio); */*SIGIO is generated (?)*/ * ... result = write(tban->port, sndBuf, cmdLen); /*request device status*/ ... /*Initialize data availability flag to false*/ /*Wait in a loop using sleep until availability flag is set to true by the callback function*/ /*SIGIO is generated */ bytesread = read(tban->port, local_buf, sizeof(local_buf)); */*bytesread is -1, EINTR is generated*/ *Although this code works fine with Linux, is there something in it that is missing for FreeBSD? Or is it a bug/limitation of the uftdi driver? Thanks a lot!