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]

A really strange problem using serial port....


Hi!

On the hardware that I am using (mediaEngine from Brightstar with
StrongArm), I have two serial ports.
I started from the template for nanoEngine.
What I want to do is to connect both COM1 and COM2, and use them.
So what I did was to include "dev/ser1" (under Serial device drivers ->
Hardware serial device drivers -> ARM SA11x0 ..) as
well as the TTY mode channel #1 (Serial device drivers -> TTY mode serial
device driv. -> TTY mode ch. #1)

This should give me a TTY compatible COM2, no???

What I did afterwards was to write a testprogram that would write to COM2 of
the hardware:

#include <stdio.h>                      /* printf */
#include <string.h>                     /* strlen */
#include <cyg/kernel/kapi.h>            /* All the kernel specific stuff */
#include <cyg/io/io.h>                  /* I/O functions */
#include <cyg/hal/hal_arch.h>           /* CYGNUM_HAL_STACK_SIZE_TYPICAL */
#include <cyg/io/ttyio.h>
#include <cyg/io/serialio.h>

int cyg_user_start(void)
{
  	cyg_io_handle_t serial_handle;
	Cyg_ErrNo ErrorLookup,ErrorNumberWrite;
	char strang[3];
	cyg_uint32 len;

	//Find device
	ErrorLookup = cyg_io_lookup("/dev/ser1",&serial_handle );
	if(ErrorLookup != 0)
	{
		printf("COM2-lookup FAILED! \n");
	}

	strang[0]='H';
	strang[1]='E';
	strang[2]='J';

	len=sizeof(strang);

	ErrorNumberWrite = cyg_io_write(serial_handle,&strang,&len);
	if(ErrorNumberWrite != 0)
	{
		printf("COM2-writing FAILED \n");
	}
}

The strange thing is that the functions cyg_io_lookup and cyg_io_write both
return 0, which means that everything is fine, and that
it found the port I was looking for AND performed a succesful write
operation...
But the only problem is that I DON'T get any output on the terminal
connected to COM2...
I also tried with "dev/tty1" instead of "dev/ser1", but still got the same
results...

I thought that maybe it's the Baudrate etc which could be wrong. So I
included the following after the Lookup:


	//Set up device
//	ser_info.baud = CYGNUM_SERIAL_BAUD_38400;
//	ser_info.stop = CYGNUM_SERIAL_STOP_1;
//	ser_info.parity = CYGNUM_SERIAL_PARITY_EVEN;
//	ser_info.word_length = CYGNUM_SERIAL_WORD_LENGTH_8;
//	ser_info.flags = CYG_SERIAL_FLAGS_DEFAULT;

//	config_len = sizeof(ser_info);

//	err = cyg_io_set_config(serial_handle,
//		CYG_IO_SET_CONFIG_SERIAL_INFO,
//		&ser_info,&config_len);
//	if (ENOERR != err) {
//		serial_handle = 0; //ERROR
//	}

But when I did this, I saw in the debugger that the execution gets "stuck"
at the line where I say:
err =
cyg_io_set_config(serial_handle,CYG_IO_SET_CONFIG_SERIAL_INFO,&ser_info,&con
fig_len);

I am really confused. Could someone please help me with this problem?
I mean, if COM2 is NOT connected ( error in the eCos "binding") I should not
get an OK flag
from the two methods??? The same goes if COM2 is not Physically connected???

Thanks a lot in advance!!

Best regards
Arif


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