From owner-freebsd-hackers Thu May 27 8:17:32 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from picnic.mat.net (picnic.mat.net [206.246.122.133]) by hub.freebsd.org (Postfix) with ESMTP id 7FED5158AB for ; Thu, 27 May 1999 08:17:12 -0700 (PDT) (envelope-from chuckr@picnic.mat.net) Received: from localhost (chuckr@localhost) by picnic.mat.net (8.9.3/8.8.5) with ESMTP id KAA27745; Thu, 27 May 1999 10:59:39 -0400 (EDT) Date: Thu, 27 May 1999 10:59:39 -0400 (EDT) From: Chuck Robey To: Max Gotlib Cc: hackers@FreeBSD.ORG Subject: Re: Serial ports programming In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, 27 May 1999, Max Gotlib wrote: > Hi! > > Some days ago I've faced with the following problem: > I need some kind of action (while coding user space > program actively handling the serial port) to get > sure all the bytes I've wrote to it are _transmitted_. > I know about "ioctl(fd, TIOCDRAIN)", but this ioctl > is accomplished with tty buffers draining to (probably) > FIFO buffer of the serial port. Is there any (portable > preferably) way to get an acknolege or to block until > FIFO buffer is cleared? The situation is that I can't > simply write additional 64 bytes (I did not see any > serial ports with FIFO larger than 64 bytes) and > drain the tty buffers - I have to catch the exact > moment ... The rate that characters drain from a UART is determined by the currently active bit rate AND the absence of any change in the DTR and CTS lines. You can sleep the time involved in transmitting the characters. You can set up to be notified of any changes in the state of the DTR and CTS lines, from the driver, and do that portably too (signals). As long as you don't get a signal to indicate the change, and you wait the time period it takes to drain the fifo, then you can rely on the fact that the UART is drained. This is no indication that the characters actually got to the other end, of course, but they'll have left your UART. > > Thanks in advance, > Max. > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > ----------------------------+----------------------------------------------- Chuck Robey | Interests include any kind of voice or data chuckr@picnic.mat.net | communications topic, C programming, and Unix. 213 Lakeside Drive Apt T-1 | Greenbelt, MD 20770 | I run picnic (FreeBSD-current) (301) 220-2114 | and jaunt (Solaris7). ----------------------------+----------------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message