This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: Serial port problem
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Ubhay <ubhay dot kumar at induslogic dot com>
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: Thu, 11 May 2006 22:44:53 +0200
- Subject: Re: [ECOS] Serial port problem
- References: <000001c6752d$d2679660$7a02a8c0@synapse.com>
On Fri, May 12, 2006 at 12:35:08AM +0530, Ubhay wrote:
> Hi,
>
> Problem statement:
> *******************
>
> I am having problem getting the printer device work which is connected on
> serial port 0 (COM1).
>
> Configuration:
> **************
>
> I have successfully loaded and run "hello world" and "serial" program using
> i386 arch configurations on my target machine. To load the hello world
> program i use hyperterminal and connect to target using tcp/ip (not using
> serial port, as I do not have the null modem cable).
>
> My target machine is a usual pentium 4 based PC.
>
> My Code:
> ********
> static void simple_prog(CYG_ADDRESS data)
> {
> cyg_io_handle_t handle;
> cyg_io_handle_t handle1;
> cyg_uint32 i;
> cyg_serial_info_t si;
> Cyg_ErrNo err,err1;
> const char test_string[] = {(char)0x7E,(char)0xB2,(char)0xF0,
> (char)'a',(char)'a',(char)'a',(char)'a',(char)'a',(char)'a',(char)'a',(char)
> 'a',(char)'a',(char)'a',(char)'a',(char)'a',(char)'a',(char)'a',(char)'a',(c
> har)'a',(char)'a',(char)'a',(char)'a',(char)'a',(char)'a',(char)'a',(char)'a
> ',(char)'a',(char)0x04,(char)70};
>
> cyg_uint32 len = strlen(test_string);
>
>
>
> printf("Starting serial example\n");
>
> err = cyg_io_lookup( "/dev/haldiag", &handle );
> err1 = cyg_io_lookup( "/dev/ser0", &handle1 );
>
>
> si.baud = CYGNUM_SERIAL_BAUD_19200;
> si.word_length = CYGNUM_SERIAL_WORD_LENGTH_8;
> si.stop = CYGNUM_SERIAL_STOP_1;
> si.parity = CYGNUM_SERIAL_PARITY_NONE;
> si.flags = 0;
> i = sizeof(si);
>
> cyg_io_set_config(handle, CYG_IO_SET_CONFIG_SERIAL_INFO, &si, &i);
> cyg_io_set_config(handle1, CYG_IO_SET_CONFIG_SERIAL_INFO, &si, &i);
>
> if (ENOERR == err) {
> printf("Found /dev/haldiag. Writing string....\n");
> err = cyg_io_write( handle, test_string, &len );
> }
>
> if (ENOERR == err1) {
> printf("Found /dev/serial1. Writing string....\n");
> err1 = cyg_io_write( handle1, test_string, &len );
> }
>
> if (ENOERR == err) {
> printf("I think I wrote the string. Did you see it?\n");
> }
>
> if (ENOERR == err1) {
> printf("I think I wrote the string. Did you see it?\n");
> }
>
> printf("Serial example finished\n");
>
> }
>
> END of Code
> ***************************
>
> Behavior of the code:
> ***********************
>
> The code successfully finds and open both the ports (as I don't get any err
> or err1 in the code above). But though I see the text on console nothing
> happens on my printer.
Does it need a \n at the end to make the printer do anything?
> One more problem which I have noticed is following:
>
> When i boot the target PC (with the printer connected on serial port 0 i.e
> COM1) the led display of printers go red (from the normal green) even before
> I load or run any program .
>
> Then after I load and run the code (above) the printer's led becomes green
> again (after the program finishes).
> I could not understand this behavior too.
Check the manual for the printer. Does it need any of the handshaking
lines set? DCE, DTE, CTS, RTS etc.....
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss