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]

Serial port problem


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.

I have written the same text "test_string" (below) in my window based java
program and it successfully prints. 

"
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};
"

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. 


What I have tried
*****************

I have enabled CYGPKG_IO_SERIAL in my ecos image (as was suggested somewhere
in the mailing list archive).
I have also tried changing "debug serial port", "default console channel"
and "disagnostic serial port" to 1 from the default value of 0 in both
redboot and ecos images.


Please help me solve this problem.

Regards,
Ubhay Kumar 
Jr. Architect
Induslogic Inc.
The Leader in Software Product Engineering
B-34/1,  Sector 59
Noida, India 201301
Phone + 91.120.434.2302
Mobile +91.981.120.4901
ubhay.kumar@induslogic.com
www.induslogic.com


--
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]