public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Serial port problem
@ 2006-05-11 19:36 Ubhay
  2006-05-11 20:53 ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: Ubhay @ 2006-05-11 19:36 UTC (permalink / raw)
  To: ecos-discuss

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ECOS] Serial port problem
  2006-05-11 19:36 [ECOS] Serial port problem Ubhay
@ 2006-05-11 20:53 ` Andrew Lunn
  2006-05-12 13:05   ` Ubhay
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2006-05-11 20:53 UTC (permalink / raw)
  To: Ubhay; +Cc: ecos-discuss

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [ECOS] Serial port problem
  2006-05-11 20:53 ` Andrew Lunn
@ 2006-05-12 13:05   ` Ubhay
  0 siblings, 0 replies; 5+ messages in thread
From: Ubhay @ 2006-05-12 13:05 UTC (permalink / raw)
  To: ecos-discuss

Hi Andrew,

Thanks for your reply.  

I have checked my printer's configuration. It does not work in flow control
RTSCTS_OUT (i.e.  Flow control for outgoing packets) for all other flow
control it works. I have cheked this using my java code and javax.comm
library.

I tried followings:

1. In the ecos image I checked the flow control setting which was set to
software control. I changed that to hardware and the mode to "NONE". 
2. In redboot I don't see any flow control option in serial device driver
package. So my question is how do I set the option to "hardware/NONE" in
redboot image? I have built redboot by following ecos eBook.


One more observation
********************

When I change the serail port baud rate to 19200
(cygnum_hal_virtual_vector_console_channel_baud and
cygnum_hal_virtual_vector_debug_channel_baud in redboot image) my ethernet
connection became very slow and I was not able to load my applications on
target device (I have explained my hardware setup in my previous mail,
basically I use tcp/ip to connect to target device using hyperterm). I could
not quite relate this as I changed the baud rate of serial port and how this
should effect the network speed etc. Once I changed this back to 38400
(default) I was able to load apps again. 
I was trying 19200 (as this is the baud required by the printer).

 

Thanks,
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


-----Original Message-----
From: ecos-discuss-owner@ecos.sourceware.org
[mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of Andrew Lunn
Sent: Friday, May 12, 2006 2:15 AM
To: Ubhay
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] Serial port problem


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


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ECOS] Serial port problem
  2002-05-28  5:38 George Mathew
@ 2002-05-28  6:15 ` Andrew Lunn
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2002-05-28  6:15 UTC (permalink / raw)
  To: George Mathew; +Cc: ecos-discuss

On Tue, May 28, 2002 at 12:38:05PM -0000, George Mathew wrote:
> Hi all
>       I'm trying to write a program to open a com port and write 
> data to it.
>       I tried with  various combination
> 
>         cyg_io_lookup("COM1",handle);
>         cyg_io_lookup("//./COM1",handle);
>         cyg_io_lookup("COM1:",handle);

Try think Unix not M$

/dev/tty0
/dev/tty1

The exact name will depend on your target and configuration. Look in
the ecos.ecc file.

    Andrew


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ECOS] Serial port problem
@ 2002-05-28  5:38 George Mathew
  2002-05-28  6:15 ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: George Mathew @ 2002-05-28  5:38 UTC (permalink / raw)
  To: ecos-discuss

Hi all
      I'm trying to write a program to open a com port and write 
data to it.
      I tried with  various combination

        cyg_io_lookup("COM1",handle);
        cyg_io_lookup("//./COM1",handle);
        cyg_io_lookup("COM1:",handle);

      ... ..
      But all the above cases returns an error value -2  which 
says that "No such entity".

      What i should do to open the com port?

      I'm using cygwin on windows XP

      Regards
        George


_________________________________________________________
Click below to visit monsterindia.com and review jobs in India or 
Abroad
http://monsterindia.rediff.com/jobs


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-05-12 13:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-11 19:36 [ECOS] Serial port problem Ubhay
2006-05-11 20:53 ` Andrew Lunn
2006-05-12 13:05   ` Ubhay
  -- strict thread matches above, loose matches on Subject: below --
2002-05-28  5:38 George Mathew
2002-05-28  6:15 ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).