This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Problem opening second serial port on EB40A
- From: "Sidharth Jandhyala" <sidharth at clarinox dot com>
- To: <ecos-discuss at sources dot redhat dot com>
- Date: Tue, 2 Mar 2004 15:33:22 +1100
- Subject: [ECOS] Problem opening second serial port on EB40A
- Organization: Clarinox Pty Ltd
- Reply-to: <sidharth at clarinox dot com>
Hello,
I am having trouble using the second serial port on the eb40A. Let me
explain my setup
1) I have built a configuration using the graphical tool with the
following settings (default package)
CYGDAT_IO_SERIAL_TTY_CONSOLE = "/dev/ttydiag"
CYGDAT_IO_SERIAL_TTY_TTY0_DEV = "/dev/ser0"
CYGDAT_IO_SERIAL_TTY_TTY1_DEV = "dev/ser1"
2) I have serial A of the board connected to arm-elf-gdb
3) I have serial B of the board connected to another computer running
hyperterminal
4) My sample hello world program is shown below
/*-------------------------------------CODE STARTS
HERE---------------------------------*/
#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> /* */
#include <pkgconf/hal.h>
#include <cyg/infra/cyg_type.h> // base types
#include <cyg/hal/hal_io.h> // low level i/o
#include <cyg/hal/var_io.h> // common registers
#include <cyg/hal/plf_io.h>
#include <cyg/io/serialio.h>
#include <cyg/io/io_diag.h>
int main (void)
{
cyg_io_handle_t serialA;
Cyg_ErrNo errA;
cyg_io_handle_t serialB;
Cyg_ErrNo errB;
const char test_string[] = "serial A is working correctly!\n";
const char test_string2[] = "serial B is working correctly\n";
cyg_uint32 len = strlen(test_string);
cyg_uint32 len2 = strlen(test_string2);
printf("Starting serial example\n");
errA = cyg_io_lookup( "/dev/haldiag", &serialA );
if (ENOERR == errA)
{
printf("Found /dev/haldiag. Writing string....\n");
}
errB = cyg_io_lookup( "/dev/ser1", &serialB );
if (ENOERR == errB)
{
printf("Found /dev/ser1 Writing string....\n");
}
for (;;)
{
write to serial port */
errA = cyg_io_write( serialA, test_string, &len );
errB = cyg_io_write(serialB, test_string2, &len2);
hal_at91_led_on(0xffffffff);
cyg_thread_delay(100);
hal_at91_led_off(0xffffffff);
cyg_thread_delay(100);
}
} //End main
/*-------------------------------------CODE ENDS
HERE---------------------------------*/
When I run the program I see the message "serial A is working correctly" on
the console and all the LEDs flash on and off. However, I see no message of
any kind in hyperterminal.
Debugging reveals that errB = -2 ("No such entity" as described by
codes.h").
What have I done wrong? I am a bit confused at what exactly haldiag does?
I have seen a similar mail to this in the mailing list
http://sources.redhat.com/ml/ecos-discuss/2001-04/msg00466.html but this did
not shed any light on my problem.
Any help on this would be greatly appreciated. Thanks in advance.
Regards,
Sidharth
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss