This is the mail archive of the ecos-discuss@sources.redhat.com 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]

RE: EB40 Serial port #1 question.


The code below was what I used to test my serial #1 port on EB40.  For 
the device name part, I tried both the "/dev/tty1" and "/dev/ser1".  However, 
only "cyg_io_write" can output to serial #1.  And only "printf" can output to 
serial #0 port.  No "err" in all parts of the program during execution.  It seems
that the serial port #1 works fine when using "cyg_io_write()", but cannot
be accessed using fileIO type of operation.  Is that normal? 

Can I configure serial port #1 so that I can use "fprintf" or "printf" for my specific
debugging purpose?


In the __DEVTAB__[] part, the following entries are in my configuration.
[0]:	name		/dev/ttydiag
	dep_name		/dev/haldiag
[1]:	name		/dev/tty1
	dep_name		/dev/ser1
[2]:	name		/dev/haldiag
	dep_name		0x0
[3]:	name		/dev/ser0
	dep_name		0x0
[4]:	name		/dev/ser1
	dep_name		0x0

<<<<<<<<<<<<<<<<<<<<PROGRAM BEGIN>>>>>>>>>>>>>>>>>>
#include <pkgconf/hal.h>
#include <pkgconf/kernel.h>
#include <pkgconf/io_fileio.h>

#include <cyg/kernel/ktypes.h>         // base kernel types
#include <cyg/infra/cyg_trac.h>        // tracing macros
#include <cyg/infra/cyg_ass.h>         // assertion macros

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <dirent.h>

#include <cyg/fileio/fileio.h>

#include <cyg/infra/testcase.h>
#include <cyg/infra/diag.h>            // HAL polled output
#include <cyg/kernel/kapi.h>            /* All the kernel specific stuff */
#include <cyg/io/io.h>                  /* I/O functions */

int main( int argc, char **argv )
{
	FILE		*out1;
	cyg_io_handle_t handle;
	Cyg_ErrNo err;
	const char test_string[] = "serial example is working correctly!\n";
	cyg_uint32 len = strlen(test_string);
	
    err = cyg_io_lookup( "/dev/tty1", &handle );
    if (ENOERR == err) {
        err = cyg_io_write( handle, test_string, &len );
    }	    
    	err = printf ("test0\n");
    	out1 = fopen ("/dev/tty1","wt");
    	err = fprintf (out1,"test1\n");
    	err = fclose (out1);
    	out1 = fopen ("/dev/haldiag","wt");
    	err = fprintf (out1,"test2\n");
    	err = fclose (out1);
exit_0:
	goto exit_0;
}
<<<<<<<<<<<<<<<<<<<<PROGRAM END>>>>>>>>>>>>>>>>>>

-----Original Message-----
From: jlarmour@cambridge.redhat.com [mailto:jlarmour@cambridge.redhat.com]On Behalf Of Jonathan Larmour
Sent: Wednesday, October 10, 2001 3:48 AM
To: Felix Wong
Cc: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] EB40 Serial port #1 question.


Felix Wong wrote:
> 
> I am going to use EB40's second serial port for my tty display purpose.
> I have tried to use fopen("/dev/ser1","rw") to get a file pointer for my
> tty.  Then I used fprintf to generate output to the serial device.
> However, no display was shown in the terminal monitor.  The baud rate of
> both sides I have set to 38400 N81.

Try using /dev/tty1. 

Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine

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