public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Serial port contention
@ 2006-08-10 14:15 David Ho
  2006-08-16 14:13 ` [ECOS] " David Ho
  0 siblings, 1 reply; 2+ messages in thread
From: David Ho @ 2006-08-10 14:15 UTC (permalink / raw)
  To: eCos discuss list

Hi,

I am debugging issues with my serial port.  What I need to do is to be
able to share one serial port for diag output and SLIP communication.

As I dig deeper I found out that the serial port is configured to do
blocking reads.  However, an cyg_io_read always returns char '\0' even
when nothing is received.

Has anyone come across this issue?  Is there a good preventive measure
I can use to make sure there is no contention?

Thanks, David

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* [ECOS] Re: Serial port contention
  2006-08-10 14:15 [ECOS] Serial port contention David Ho
@ 2006-08-16 14:13 ` David Ho
  0 siblings, 0 replies; 2+ messages in thread
From: David Ho @ 2006-08-16 14:13 UTC (permalink / raw)
  To: eCos discuss list

> Has anyone come across this issue?  Is there a good preventive measure
> I can use to make sure there is no contention?

This is what I do when I need to debug my system while my only serial
port is being used.
Stolen from a ppc board, all credits go to the originator(s).

David
---

commit 5b20c814009df6a19e63adc9058be47763e5496e
Author: David Ho <davidho@nanometrics.ca>
Date:   Mon Aug 14 07:52:59 2006 -0400

    Write diagnostics to RAM.

diff --git a/packages/hal/arm/at91/var/current/src/hal_diag.c
b/packages/hal/arm/at91/var/current/src/hal_diag.c
index 73c4830..34a8c3f 100644
--- a/packages/hal/arm/at91/var/current/src/hal_diag.c
+++ b/packages/hal/arm/at91/var/current/src/hal_diag.c
@@ -65,6 +65,49 @@ #include <cyg/hal/hal_diag.h>

 #include <cyg/hal/var_io.h>             // USART registers

+#define CYGDBG_DIAG_BUF
+
+#ifdef CYGDBG_DIAG_BUF
+// Keep diag messages in a buffer for later [re]display
+
+int enable_diag_uart = 0;
+int enable_diag_buf = 1;
+//static char diag_buf[40960*4];
+static char diag_buf[4096*4];
+static int  diag_buf_ptr = 0;
+
+/**
+ * Turn this into a circular buffer - DKWH
+ */
+static void
+diag_putc(char c)
+{
+    if (enable_diag_buf) {
+        diag_buf[diag_buf_ptr++] = c;
+        if (diag_buf_ptr == sizeof(diag_buf)) {
+           diag_buf_ptr--;
+       }
+    }
+}
+
+/**
+ * Restore buffer after buffer dump - DKWH
+ */
+void
+dump_diag_buf(int start, int len)
+{
+    int i;
+    enable_diag_uart = 1;
+    enable_diag_buf = 0;
+    if (len == 0) len = diag_buf_ptr;
+    diag_printf("\nDiag buf\n");
+    for (i = start;  i < len;  i++) {
+        hal_diag_write_char(diag_buf[i]);
+    }
+    enable_diag_buf = 1;
+}
+#endif // CYGDBG_DIAG_BUF
+
 //-----------------------------------------------------------------------------
 typedef struct {
     cyg_uint8* base;
@@ -104,6 +147,12 @@ cyg_hal_plf_serial_putc(void *__ch_data,
 {
     cyg_uint8* base = ((channel_data_t*)__ch_data)->base;
     cyg_uint32 status, ch;
+
+#ifdef CYGDBG_DIAG_BUF
+    diag_putc(c);
+    if (!enable_diag_uart) return;
+#endif // CYGDBG_DIAG_BUF
+
     CYGARC_HAL_SAVE_GP();

     do {

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

end of thread, other threads:[~2006-08-16 14:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-10 14:15 [ECOS] Serial port contention David Ho
2006-08-16 14:13 ` [ECOS] " David Ho

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 read-only IMAP folder(s) and NNTP newsgroup(s).