linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Is it normal for serial ports to drop characters at the end?
@ 2000-05-03 15:30 Brown, David (dbrown03)
  2000-05-03 19:27 ` Marcus Sundberg
  0 siblings, 1 reply; 4+ messages in thread
From: Brown, David (dbrown03) @ 2000-05-03 15:30 UTC (permalink / raw)
  To: linuxppc-embedded


I see characters dropped at the end of a write to a serial port.  Surely
that isn't normal.
I'm using the current MontaVista 2.2.13 kernel patched for my custom
860-based board.  The serial ports are running at 9600.

When I do this:
init-2.00# help while >/dev/ttyS1

I see this (on ttyS1):
while: while COMMANDS; do COMMANDS; done
    Expand and execute COMMANDS as long as the final command in the
    `while' COMMANDS has an exit status of .

It's slightly different each time, garbling or dropping characters from
"zero."
This happens on ttyS1 (SMC2), ttyS2 (SCC2), and ttyS3 (SCC3).
If I send a longer message (help set >/dev/ttyS1) I see the same thing: all
prints okay except the last several characters.

Same board as has SCC serial problems when ethernet is used, but I'm
thinking its not related to that since this problem happens for SMC2 as
well.  Could it be that when a serial port is closed, the uart is disabled
immediately instead of waiting for output to finish?

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Is it normal for serial ports to drop characters at the end?
  2000-05-03 15:30 Is it normal for serial ports to drop characters at the end? Brown, David (dbrown03)
@ 2000-05-03 19:27 ` Marcus Sundberg
  2000-05-03 19:53   ` Dan Malek
  0 siblings, 1 reply; 4+ messages in thread
From: Marcus Sundberg @ 2000-05-03 19:27 UTC (permalink / raw)
  To: Brown, David (dbrown03); +Cc: linuxppc-embedded


"Brown, David (dbrown03)" <DBrown03@harris.com> writes:

> I see characters dropped at the end of a write to a serial port.  Surely
> that isn't normal.
> I'm using the current MontaVista 2.2.13 kernel patched for my custom
> 860-based board.  The serial ports are running at 9600.
>
> When I do this:
> init-2.00# help while >/dev/ttyS1

[snip]

> well.  Could it be that when a serial port is closed, the uart is disabled
> immediately instead of waiting for output to finish?

Right on target.
rs_8xx_wait_until_sent() will wait for the *first* buffer descriptor
to be finished, instead of waiting for the last one as it should.
This patch fixes that problem:

diff -bu uart.orig uart.c
--- uart.c.orig	Wed May  3 20:25:09 2000
+++ uart.c	Fri Apr 28 20:08:15 2000
@@ -1710,6 +1718,13 @@
 	 * be at least two characters waiting to be sent after the buffers
 	 * are empty.
 	 */
+	bdp = info->tx_cur;
+	/* We want to wait for the last buffer, not the first. */
+	if (bdp == info->tx_bd_base) {
+		bdp += (TX_NUM_FIFO-1);
+	} else {
+		bdp--;
+	}
 	do {
 #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
 		printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
@@ -1721,7 +1736,6 @@
 			break;
 		if (timeout && ((orig_jiffies + timeout) < jiffies))
 			break;
-		bdp = info->tx_cur;
 	} while (bdp->cbd_sc & BD_SC_READY);
 	current->state = TASK_RUNNING;
 #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT


There is also a problem with kernel messages being truncated when
an application open the serial console. This patch should fix that:

diff -bu uart.orig uart.c
--- uart.c.orig	Wed May  3 20:25:09 2000
+++ uart.c	Fri Apr 28 20:08:15 2000
@@ -915,8 +909,20 @@
 		info->read_status_mask &= ~BD_SC_EMPTY;
 	save_flags(flags); cli();

+	/* Make sure last buffer has been sent. */
+	{
+		volatile cbd_t	*bdp;
+		bdp = info->tx_cur;
+		if (bdp == info->tx_bd_base) {
+			bdp += (TX_NUM_FIFO-1);
+		} else {
+			bdp--;
+		}
+		while (bdp->cbd_sc & BD_SC_READY);
+	}
+
 	/* Start bit has not been added (so don't, because we would just
 	 * subtract it later), and we need to add one for the number of
 	 * stops bits (there is always at least one).
 	 */
 	bits++;

//Marcus
--
-------------------------------+-----------------------------------
        Marcus Sundberg        |       Phone: +46 707 452062
  Embedded Systems Consultant  |      Email: marcus@cendio.se
       Cendio Systems AB       |       http://www.cendio.se/

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Is it normal for serial ports to drop characters at the end?
  2000-05-03 19:27 ` Marcus Sundberg
@ 2000-05-03 19:53   ` Dan Malek
  2000-05-03 20:05     ` Marcus Sundberg
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Malek @ 2000-05-03 19:53 UTC (permalink / raw)
  To: Marcus Sundberg; +Cc: Brown, David (dbrown03), linuxppc-embedded


Marcus Sundberg wrote:

> Right on target.
> rs_8xx_wait_until_sent() will wait for the *first* buffer descriptor
> to be finished, instead of waiting for the last one as it should.
> This patch fixes that problem:

That's part of it, but we also need to perform a graceful shutdown
of the port so we wait until the hardware FIFOs are empty.  Waiting
for the buffer descriptor just means the CPM moved the last data
from the buffer, not that it has gone out the wire.

I thought I did this once.....but, why are you closing devices anyway :-).


	-- Dan

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Is it normal for serial ports to drop characters at the end?
  2000-05-03 19:53   ` Dan Malek
@ 2000-05-03 20:05     ` Marcus Sundberg
  0 siblings, 0 replies; 4+ messages in thread
From: Marcus Sundberg @ 2000-05-03 20:05 UTC (permalink / raw)
  To: Dan Malek; +Cc: Brown, David (dbrown03), linuxppc-embedded


Dan Malek <dan@netx4.com> writes:

> Marcus Sundberg wrote:
>
> > Right on target.
> > rs_8xx_wait_until_sent() will wait for the *first* buffer descriptor
> > to be finished, instead of waiting for the last one as it should.
> > This patch fixes that problem:
>
> That's part of it, but we also need to perform a graceful shutdown
> of the port so we wait until the hardware FIFOs are empty.  Waiting
> for the buffer descriptor just means the CPM moved the last data
> from the buffer, not that it has gone out the wire.

Sure, but the above "works perfect for me(tm)", at least in 9600bps.

> I thought I did this once.....but, why are you closing devices anyway :-).

I think I experienced this first when using the busybox init
implementation, which IIRC opens and closes /dev/console for each
message. Otherwise I've never seen it in a real application.

/Marcus
--
-------------------------------+-----------------------------------
        Marcus Sundberg        |       Phone: +46 707 452062
  Embedded Systems Consultant  |      Email: marcus@cendio.se
       Cendio Systems AB       |       http://www.cendio.com

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2000-05-03 20:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-05-03 15:30 Is it normal for serial ports to drop characters at the end? Brown, David (dbrown03)
2000-05-03 19:27 ` Marcus Sundberg
2000-05-03 19:53   ` Dan Malek
2000-05-03 20:05     ` Marcus Sundberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).