Skip to contentSkip to conversation

Add background serial print and correct search_device function

PATCH New Ryan CHEN 3 participants 3 messages Aug 20, 2008 – Sep 6, 2008

lore
Share & tools
lore

Ryan CHEN

author
#0 lore raw

PATCH 1/1 Add background serial print and correct search_device function

The patch introduces a new macro 'CFG_BG_CONSOLE_SERIAL'.
It means print messages through serial port although current console isn't serial port. It is important for debugging and looks like multi-consoles in Linux but without input.

Another modification in the patch is that verify if search_device function found device. If found, return dev. Otherwise, return NULL.

---
 common/console.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
common/console.c +13 -0
index 1b095b1..c60baef 100644
@@ -132,12 +132,20 @@ void fputc (int file, const char c)
 {
 	if (file < MAX_FILES)
 		stdio_devices[file]->putc (c);
+#ifdef CFG_BG_CONSOLE_SERIAL
+	if((unsigned int)stdio_devices[file]->putc != (unsigned int)serial_putc)
+		serial_putc (c);
+#endif/*CFG_BG_CONSOLE_SERIAL*/
 }
 
 void fputs (int file, const char *s)
 {
 	if (file < MAX_FILES)
 		stdio_devices[file]->puts (s);
+#ifdef CFG_BG_CONSOLE_SERIAL
+	if((unsigned int)stdio_devices[file]->puts != (unsigned int)serial_puts)
+		serial_puts(s);
+#endif/*CFG_BG_CONSOLE_SERIAL*/
 }
 
 void fprintf (int file, const char *fmt, ...)
@@ -377,6 +385,7 @@ device_t *search_device (int flags, char *name)
 {
 	int i, items;
 	device_t *dev = NULL;
+	int found_flag = 0;
 
 	items = ListNumItems (devlist);
 	if (name == NULL)
@@ -385,9 +394,13 @@ device_t *search_device (int flags, char *name)
 	for (i = 1; i <= items; i++) {
 		dev = ListGetPtrToItem (devlist, i);
 		if ((dev->flags & flags) && (strcmp (name, dev->name) == 0)) {
+			found_flag = 1;
 			break;
 		}
 	}
+	
+	if(!found_flag)
+		return NULL;
 	return dev;
 }
 #endif /* CFG_CONSOLE_IS_IN_ENV || CONFIG_SPLASH_SCREEN */
Signature · 1 line
1.6.0.rc1
#1 lore raw

PATCH 1/1 Add background serial print and correct search_device function

Dear Ryan CHEN,

Quoted 8 lines · In message <[email protected]> you wrote:

The patch introduces a new macro 'CFG_BG_CONSOLE_SERIAL'.
It means print messages through serial port although current console isn't serial port. It is important for debugging and looks like multi-consoles in Linux but without input.

Another modification in the patch is that verify if search_device function found device. If found, return dev. Otherwise, return NULL.

This patch doesn't apply any more due to the changes to the list and device code. Can you please rebase it?

But - I recommend to wait a bit doing this, until Gary Jennejohn has posted the input multiplexing stuff he is working on, which will probably obsolete parts of your code (in an hopefully more elegant and more general way).

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Substitute "damn" every time you're inclined to write "very"; your
editor will delete it and the writing will be just as it should be.
                - Mark Twain
#2 lore raw

PATCH 1/1 Add background serial print and correct search_device function

In reply to Ryan CHEN
Quoted 26 lines · Ryan CHEN

The patch introduces a new macro 'CFG_BG_CONSOLE_SERIAL'.
It means print messages through serial port although current console isn't serial port. It is important for debugging and looks like multi-consoles in Linux but without input.

Another modification in the patch is that verify if search_device function found device. If found, return dev. Otherwise, return NULL.

---
 common/console.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

void fprintf (int file, const char *fmt, ...)

common/console.c +1 -0
@@ -377,6 +385,7 @@ device_t *search_device (int flags, char *name)
 {
 	int i, items;
 	device_t *dev = NULL;
+	int found_flag = 0;
 
 	items = ListNumItems (devlist);
 	if (name == NULL)
@@ -385,9 +394,13 @@ device_t *search_device (int flags, char *name)
 	for (i = 1; i <= items; i++) {
 		dev = ListGetPtrToItem (devlist, i);

common/console.c device_t *search_device (int flags, char *name) · line 405

Quoted 10 lines
common/console.c +4 -0
 		if ((dev->flags & flags) && (strcmp (name, dev->name) == 0)) {
+			found_flag = 1;
 			break;
 		}
 	}
+	
+	if(!found_flag)
+		return NULL;
 	return dev;
 }

This part is no more need, It's already fix by this commit c1de7a6daf9c657484e1c6d433f01fccd49a7f48

Best Regards,
J.