Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Sep 2009 16:22:41 -0400
From:      Pierre-Luc Drouin <pldrouin@pldrouin.net>
To:        freebsd-usb@freebsd.org
Subject:   Are asynchronous transfers supported by uftdi?
Message-ID:  <4AB68F11.2080202@pldrouin.net>

next in thread | raw e-mail | index | archive | help
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!




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4AB68F11.2080202>