This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Redirect stdout and stderr to diag_printf


>...I would like to see all stdout and stderr output on my console, which I am intercepting with diag_init_putc. How can I do this? I'm using eCos 2.0.

Update ecos to latest code from cvs or snapshots.

I redirected my diag_printf to the dcc channel in ARM which connected through the JTAG to the PC. My code is attached.

Keith Ross
E-Lands Communiactions Ltd, NZ
//ELANDS
#include <cyg/infra/diag.h>             // HAL polled output

#define DCC_OUTPUT_BUSY 2
#define DCC_INPUT_READY 1

cyg_uint8 USE_ARM_DCC;

externC void write_dcc(unsigned int c);
externC cyg_int32 chk_read_dcc(void);

//If JTAG (ARM) debug communications channel present
//char written will be consumed immediately (almost)
extern cyg_uint32 test_dcc(char testchar);

static void write_dcc_char(unsigned int c) {
	if (USE_ARM_DCC) {
		write_dcc(c);
	}
}

void write_dcc_string(const char* s) {
	while (*s) write_dcc_char(*s++);
}


// Wrapper used by diag_printf()
static void
_mon_write_char(char c, void **param)
{
    if (c == '\n') {
        write_dcc_char('\r');
    }
    write_dcc_char(c);
}

void dcc_init(void) {
	USE_ARM_DCC = test_dcc('>'); //set USE_ARM_DCC if JTAG detected
	
	if (USE_ARM_DCC) {
		diag_init_putc(_mon_write_char);
		diag_printf("Welcome to E-Lands E800 diag port.\n");
		diag_printf("May 2005 Keith Ross\n");
	}
}

void plf_if_init(void) {
	//This function ties dcc into ecos and diag_printf
	//if CYGINT_HAL_PLF_IF_INIT is implemented
	dcc_init();
}

cyg_int32 chk_read_dcc_char(void) {
	return chk_read_dcc();
}

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]