From owner-freebsd-hackers@FreeBSD.ORG Sun Aug 15 13:55:10 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C80B81065693 for ; Sun, 15 Aug 2010 13:55:10 +0000 (UTC) (envelope-from prt@prt.org) Received: from smtp5.uk.umis.net (smtp5.uk.umis.net [217.65.166.40]) by mx1.freebsd.org (Postfix) with ESMTP id 91ACB8FC1A for ; Sun, 15 Aug 2010 13:55:10 +0000 (UTC) Received: from kate.prtsystems.ltd.uk ([217.65.165.35]) by smtp5.uk.umis.net with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63 (FreeBSD)) (envelope-from ) id 1Okdg5-0008dy-9m; Sun, 15 Aug 2010 13:55:09 +0000 Message-ID: <4C67F1BD.9000003@prt.org> Date: Sun, 15 Aug 2010 14:55:09 +0100 From: Paul Thornton User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Ed Schouten References: <4C66D2CF.9040408@prt.org> <20100814220929.GI2978@hoeg.nl> <4C672EE1.60101@prt.org> In-Reply-To: <4C672EE1.60101@prt.org> X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org Subject: Re: Problem detecting and reacting to serial break X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Aug 2010 13:55:10 -0000 Paul Thornton wrote: > Ed Schouten wrote: >> * Paul Thornton wrote: >>> I'm using 8.0-RELEASE with uftdi and ucom driving the serial port. >> Somewhat unrelated question: have you ever tried running the this code >> on 7.x? If so, did it work? > > I've just tried this on 7.2-RELEASE (that was the only 7.x CD I could > find lurking about my desk). I've been looking into this a bit deeper, both with 7.2 and on a Linux box I had to hand. I'm using a baud rate of 250000 - which of course is non-standard; although the FTDI chip is more than capable of doing it. The tcsetattr does not like setting the baud rate to this - which works without complaint under 8 (I'm guessing this is one of the enhancements). This lack of tcsetattr success is, I suspect, causing my block on the read() call. When I set the rate to 9600, the tcsetattr succeeds, and I do get data coming back from the read - albeit baud barf. I made a quick hack to uftdireg.h and uftdi.c to add a rate of 250000 with a divisor of 12 - which results in my tcsetattr now succeeding, and the data read looking more correct. However I'm now back to the same problem as under 8.0 - the break has no effect and the position of data byte 1 wanders around the buffer. With Linux, it all works as expected - but the linux tcsetattr doesn't like the nonstandard baud rate either. However, in linux I used setserial to set a base baud rate of 24000000 and a divisor of 96 to get 250k baud rate. When I run, I have a stable buffer dump displayed which always starts with byte 1; so I'm happy that in theory my code is correct and the hardware is behaving as expected. So it seems that the answer is that I get the same behaviour with 7.2 as I did with 8.0. Paul.