public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Serial comms
@ 2009-04-14 10:06 grahamlab
  2009-04-15  7:24 ` Sergei Gavrikov
  0 siblings, 1 reply; 9+ messages in thread
From: grahamlab @ 2009-04-14 10:06 UTC (permalink / raw)
  To: ecos-discuss


Hello everyone
I am relatively new to eCos so please forgive me my questions seem naive.
I am developing software targeted at the STM3210e dev board and am trying to
get serial comms going between this board and a program running under ubuntu
via virtual box on my PC
I have a serial link between the PC and the dev kit (UART1) that uses ttyS0
to load the ecos program via gdb. This works, I can download and execute an
eCos program on the Dev board.
I have another serial link between my PC and the dev kit (UART2).
I have written 2 programs - one using eCos and one to run under ubuntu.
The eCos program opens the /dev/ser1 device and writes a string to that
device and awaits a reply.
The ubuntu opens /dev/ttyS1 and waits for a message and then writes back an
acknowledgment.

When these two programs are run I get the following results.

When the ecos program sends its data the ubuntu program receives alot of
data from the Redboot monitor and then the data from the ecos program. It
then blocks on the write. The ecos program has blocked on the read.

Why do I get data from the Redboot monitor and why do both programs block.

I have attached both programs 
http://www.nabble.com/file/p23036433/hello.cpp hello.cpp ,
http://www.nabble.com/file/p23036433/SerialTest.cpp SerialTest.cpp 

Thank you for your time
Graham


-- 
View this message in context: http://www.nabble.com/Serial-comms-tp23036433p23036433.html
Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.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] 9+ messages in thread

* Re: [ECOS] Serial comms
  2009-04-14 10:06 [ECOS] Serial comms grahamlab
@ 2009-04-15  7:24 ` Sergei Gavrikov
  2009-04-15  9:26   ` grahamlab
  0 siblings, 1 reply; 9+ messages in thread
From: Sergei Gavrikov @ 2009-04-15  7:24 UTC (permalink / raw)
  To: grahamlab; +Cc: ecos-discuss

On Tue, Apr 14, 2009 at 03:04:29AM -0700, grahamlab wrote:
> 
> Hello everyone
> I am relatively new to eCos so please forgive me my questions seem naive.
> I am developing software targeted at the STM3210e dev board and am trying to
> get serial comms going between this board and a program running under ubuntu
> via virtual box on my PC
> I have a serial link between the PC and the dev kit (UART1) that uses ttyS0
> to load the ecos program via gdb. This works, I can download and execute an
> eCos program on the Dev board.
> I have another serial link between my PC and the dev kit (UART2).
> I have written 2 programs - one using eCos and one to run under ubuntu.
> The eCos program opens the /dev/ser1 device and writes a string to that
> device and awaits a reply.
> The ubuntu opens /dev/ttyS1 and waits for a message and then writes back an
> acknowledgment.
> 
> When these two programs are run I get the following results.
> 
> When the ecos program sends its data the ubuntu program receives alot of
> data from the Redboot monitor and then the data from the ecos program. It
> then blocks on the write. The ecos program has blocked on the read.
> 
> Why do I get data from the Redboot monitor and why do both programs block.
> I have attached both programs 
> http://www.nabble.com/file/p23036433/hello.cpp hello.cpp ,
> http://www.nabble.com/file/p23036433/SerialTest.cpp SerialTest.cpp 
> 
> Thank you for your time
> Graham

Graham, it seems for me, your eCos application quite crashes (board
resets itself) and you see/get the Redboot's startup screen in your
program. Your code is terrible, you do not check return-codes!

hello.cpp:
while (1) {
    // ...
    res = read(fd, buf, 4096);
    buf[res] = 0;
    // ...
}

SerialTest.cpp:
while (1) {
    // ...
    int             b = read(fd, &buf[0], 4096);
    buf[b] = '\0';
    // ...
}

How do you think, What will happy on buf[-1] = 0 ? Read about the return
values of read(), write().

man 2 read
man 2 write

Your while() blocks are terrible things which will eat all CPU time if
they will work at all.

Your hello.cpp is written for PC and that is almost just an echo
program.  Why do not use terminal program (minicom, hyperterm) at first
to debug the eCos termios program? It seemed for me that you are not
only "new" to eCos. Why we took a time to stand up GDB for you? 

Learn programming, learn C 

http://en.wikibooks.org/wiki/C_Programming

Then learn eCos programming.


Sergei

-- 
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] 9+ messages in thread

* Re: [ECOS] Serial comms
  2009-04-15  7:24 ` Sergei Gavrikov
@ 2009-04-15  9:26   ` grahamlab
  2009-04-15 10:01     ` Sergei Gavrikov
  0 siblings, 1 reply; 9+ messages in thread
From: grahamlab @ 2009-04-15  9:26 UTC (permalink / raw)
  To: ecos-discuss




Sergei Gavrikov-4 wrote:
> 
> On Tue, Apr 14, 2009 at 03:04:29AM -0700, grahamlab wrote:
>> 
>> Hello everyone
>> I am relatively new to eCos so please forgive me my questions seem naive.
>> I am developing software targeted at the STM3210e dev board and am trying
>> to
>> get serial comms going between this board and a program running under
>> ubuntu
>> via virtual box on my PC
>> I have a serial link between the PC and the dev kit (UART1) that uses
>> ttyS0
>> to load the ecos program via gdb. This works, I can download and execute
>> an
>> eCos program on the Dev board.
>> I have another serial link between my PC and the dev kit (UART2).
>> I have written 2 programs - one using eCos and one to run under ubuntu.
>> The eCos program opens the /dev/ser1 device and writes a string to that
>> device and awaits a reply.
>> The ubuntu opens /dev/ttyS1 and waits for a message and then writes back
>> an
>> acknowledgment.
>> 
>> When these two programs are run I get the following results.
>> 
>> When the ecos program sends its data the ubuntu program receives alot of
>> data from the Redboot monitor and then the data from the ecos program. It
>> then blocks on the write. The ecos program has blocked on the read.
>> 
>> Why do I get data from the Redboot monitor and why do both programs
>> block.
>> I have attached both programs 
>> http://www.nabble.com/file/p23036433/hello.cpp hello.cpp ,
>> http://www.nabble.com/file/p23036433/SerialTest.cpp SerialTest.cpp 
>> 
>> Thank you for your time
>> Graham
> 
> Graham, it seems for me, your eCos application quite crashes (board
> resets itself) and you see/get the Redboot's startup screen in your
> program. Your code is terrible, you do not check return-codes!
> 
> hello.cpp:
> while (1) {
>     // ...
>     res = read(fd, buf, 4096);
>     buf[res] = 0;
>     // ...
> }
> 
> SerialTest.cpp:
> while (1) {
>     // ...
>     int             b = read(fd, &buf[0], 4096);
>     buf[b] = '\0';
>     // ...
> }
> 
> How do you think, What will happy on buf[-1] = 0 ? Read about the return
> values of read(), write().
> 
> man 2 read
> man 2 write
> 
> Your while() blocks are terrible things which will eat all CPU time if
> they will work at all.
> 
> Your hello.cpp is written for PC and that is almost just an echo
> program.  Why do not use terminal program (minicom, hyperterm) at first
> to debug the eCos termios program? It seemed for me that you are not
> only "new" to eCos. Why we took a time to stand up GDB for you? 
> 
> Learn programming, learn C 
> 
> http://en.wikibooks.org/wiki/C_Programming
> 
> Then learn eCos programming.
> 
> 
> Sergei
> 
> -- 
> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
> 
> 
> 
Sergei
I have used the mincom program to receive a test string from ecos
When I use a PC program of my making to read a string I receive data from
redboot before I receive the test string. I do not know why this is the case
and would appreciate any explanation

Graham
-- 
View this message in context: http://www.nabble.com/Serial-comms-tp23036433p23055275.html
Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.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] 9+ messages in thread

* Re: [ECOS] Serial comms
  2009-04-15  9:26   ` grahamlab
@ 2009-04-15 10:01     ` Sergei Gavrikov
  2009-04-15 11:15       ` grahamlab
  0 siblings, 1 reply; 9+ messages in thread
From: Sergei Gavrikov @ 2009-04-15 10:01 UTC (permalink / raw)
  To: grahamlab; +Cc: ecos-discuss

On Wed, Apr 15, 2009 at 02:01:39AM -0700, grahamlab wrote:
> 
> 
> 
> Sergei Gavrikov-4 wrote:
> > 
> > On Tue, Apr 14, 2009 at 03:04:29AM -0700, grahamlab wrote:
> >> 
> >> Hello everyone
> >> I am relatively new to eCos so please forgive me my questions seem naive.
> >> I am developing software targeted at the STM3210e dev board and am trying
> >> to
> >> get serial comms going between this board and a program running under
> >> ubuntu
> >> via virtual box on my PC
> >> I have a serial link between the PC and the dev kit (UART1) that uses
> >> ttyS0
> >> to load the ecos program via gdb. This works, I can download and execute
> >> an
> >> eCos program on the Dev board.
> >> I have another serial link between my PC and the dev kit (UART2).
> >> I have written 2 programs - one using eCos and one to run under ubuntu.
> >> The eCos program opens the /dev/ser1 device and writes a string to that
> >> device and awaits a reply.
> >> The ubuntu opens /dev/ttyS1 and waits for a message and then writes back
> >> an
> >> acknowledgment.
> >> 
> >> When these two programs are run I get the following results.
> >> 
> >> When the ecos program sends its data the ubuntu program receives alot of
> >> data from the Redboot monitor and then the data from the ecos program. It
> >> then blocks on the write. The ecos program has blocked on the read.
> >> 
> >> Why do I get data from the Redboot monitor and why do both programs
> >> block.
> >> I have attached both programs 
> >> http://www.nabble.com/file/p23036433/hello.cpp hello.cpp ,
> >> http://www.nabble.com/file/p23036433/SerialTest.cpp SerialTest.cpp 
> >> 
> >> Thank you for your time
> >> Graham
> > 
> > Graham, it seems for me, your eCos application quite crashes (board
> > resets itself) and you see/get the Redboot's startup screen in your
> > program. Your code is terrible, you do not check return-codes!
> > 
> > hello.cpp:
> > while (1) {
> >     // ...
> >     res = read(fd, buf, 4096);
> >     buf[res] = 0;
> >     // ...
> > }
> > 
> > SerialTest.cpp:
> > while (1) {
> >     // ...
> >     int             b = read(fd, &buf[0], 4096);
> >     buf[b] = '\0';
> >     // ...
> > }
> > 
> > How do you think, What will happy on buf[-1] = 0 ? Read about the return
> > values of read(), write().
> > 
> > man 2 read
> > man 2 write
> > 
> > Your while() blocks are terrible things which will eat all CPU time if
> > they will work at all.
> > 
> > Your hello.cpp is written for PC and that is almost just an echo
> > program.  Why do not use terminal program (minicom, hyperterm) at first
> > to debug the eCos termios program? It seemed for me that you are not
> > only "new" to eCos. Why we took a time to stand up GDB for you? 
> > 
> > Learn programming, learn C 
> > 
> > http://en.wikibooks.org/wiki/C_Programming
> > 
> > Then learn eCos programming.
> > 
> > 
> > Sergei
> > 
> > -- 
> > Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> > and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
> > 
> > 
> > 
> Sergei
> I have used the mincom program to receive a test string from ecos
> When I use a PC program of my making to read a string I receive data from
> redboot before I receive the test string. I do not know why this is the case
> and would appreciate any explanation
> 
> Graham

On start Redboot (by default) outs own startup screens an both serial
channels. You can see it. Run on two consoles

on 1st console:
stty speed 38400 -F /dev/ttyS0
cat /dev/ttyS0

on 2nd console:
stty speed 38400 -F /dev/ttyS1
cat /dev/ttyS1

connect cables to the board and then press a Reset button. You will see
that data will come on both consoles.

So, when board is reset, Redboot's banner already exists in PC's serial
buffer, but that lines has been not read yet (/dev/ttyS1). When you run
your PC program, it reads that portion of lines and then it read next
incoming data. So, your program should flush serial buffer before to
start that read loop.


Sergei

-- 
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] 9+ messages in thread

* Re: [ECOS] Serial comms
  2009-04-15 10:01     ` Sergei Gavrikov
@ 2009-04-15 11:15       ` grahamlab
  2009-04-15 11:29         ` Sergei Gavrikov
  0 siblings, 1 reply; 9+ messages in thread
From: grahamlab @ 2009-04-15 11:15 UTC (permalink / raw)
  To: ecos-discuss




Sergei Gavrikov-4 wrote:
> 
> On Wed, Apr 15, 2009 at 02:01:39AM -0700, grahamlab wrote:
>> 
>> 
>> 
>> Sergei Gavrikov-4 wrote:
>> > 
>> > On Tue, Apr 14, 2009 at 03:04:29AM -0700, grahamlab wrote:
>> >> 
>> >> Hello everyone
>> >> I am relatively new to eCos so please forgive me my questions seem
>> naive.
>> >> I am developing software targeted at the STM3210e dev board and am
>> trying
>> >> to
>> >> get serial comms going between this board and a program running under
>> >> ubuntu
>> >> via virtual box on my PC
>> >> I have a serial link between the PC and the dev kit (UART1) that uses
>> >> ttyS0
>> >> to load the ecos program via gdb. This works, I can download and
>> execute
>> >> an
>> >> eCos program on the Dev board.
>> >> I have another serial link between my PC and the dev kit (UART2).
>> >> I have written 2 programs - one using eCos and one to run under
>> ubuntu.
>> >> The eCos program opens the /dev/ser1 device and writes a string to
>> that
>> >> device and awaits a reply.
>> >> The ubuntu opens /dev/ttyS1 and waits for a message and then writes
>> back
>> >> an
>> >> acknowledgment.
>> >> 
>> >> When these two programs are run I get the following results.
>> >> 
>> >> When the ecos program sends its data the ubuntu program receives alot
>> of
>> >> data from the Redboot monitor and then the data from the ecos program.
>> It
>> >> then blocks on the write. The ecos program has blocked on the read.
>> >> 
>> >> Why do I get data from the Redboot monitor and why do both programs
>> >> block.
>> >> I have attached both programs 
>> >> http://www.nabble.com/file/p23036433/hello.cpp hello.cpp ,
>> >> http://www.nabble.com/file/p23036433/SerialTest.cpp SerialTest.cpp 
>> >> 
>> >> Thank you for your time
>> >> Graham
>> > 
>> > Graham, it seems for me, your eCos application quite crashes (board
>> > resets itself) and you see/get the Redboot's startup screen in your
>> > program. Your code is terrible, you do not check return-codes!
>> > 
>> > hello.cpp:
>> > while (1) {
>> >     // ...
>> >     res = read(fd, buf, 4096);
>> >     buf[res] = 0;
>> >     // ...
>> > }
>> > 
>> > SerialTest.cpp:
>> > while (1) {
>> >     // ...
>> >     int             b = read(fd, &buf[0], 4096);
>> >     buf[b] = '\0';
>> >     // ...
>> > }
>> > 
>> > How do you think, What will happy on buf[-1] = 0 ? Read about the
>> return
>> > values of read(), write().
>> > 
>> > man 2 read
>> > man 2 write
>> > 
>> > Your while() blocks are terrible things which will eat all CPU time if
>> > they will work at all.
>> > 
>> > Your hello.cpp is written for PC and that is almost just an echo
>> > program.  Why do not use terminal program (minicom, hyperterm) at first
>> > to debug the eCos termios program? It seemed for me that you are not
>> > only "new" to eCos. Why we took a time to stand up GDB for you? 
>> > 
>> > Learn programming, learn C 
>> > 
>> > http://en.wikibooks.org/wiki/C_Programming
>> > 
>> > Then learn eCos programming.
>> > 
>> > 
>> > Sergei
>> > 
>> > -- 
>> > Before posting, please read the FAQ:
>> http://ecos.sourceware.org/fom/ecos
>> > and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>> > 
>> > 
>> > 
>> Sergei
>> I have used the mincom program to receive a test string from ecos
>> When I use a PC program of my making to read a string I receive data from
>> redboot before I receive the test string. I do not know why this is the
>> case
>> and would appreciate any explanation
>> 
>> Graham
> 
> On start Redboot (by default) outs own startup screens an both serial
> channels. You can see it. Run on two consoles
> 
> on 1st console:
> stty speed 38400 -F /dev/ttyS0
> cat /dev/ttyS0
> 
> on 2nd console:
> stty speed 38400 -F /dev/ttyS1
> cat /dev/ttyS1
> 
> connect cables to the board and then press a Reset button. You will see
> that data will come on both consoles.
> 
> So, when board is reset, Redboot's banner already exists in PC's serial
> buffer, but that lines has been not read yet (/dev/ttyS1). When you run
> your PC program, it reads that portion of lines and then it read next
> incoming data. So, your program should flush serial buffer before to
> start that read loop.
> 
> 
> Sergei
> 
> -- 
> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
> 
> 
> 
Thanks for the info Sergei
Will the Redboot banner get output when I start my ecos program. This is
what seems to be happening
I flush the serial buffer before reading data in the PC program 
When I run the PC program it is waiting for input.
I then run the ecos program and get the redboot stuff in the PC program.

-- 
View this message in context: http://www.nabble.com/Serial-comms-tp23036433p23056299.html
Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.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] 9+ messages in thread

* Re: [ECOS] Serial comms
  2009-04-15 11:15       ` grahamlab
@ 2009-04-15 11:29         ` Sergei Gavrikov
  2009-04-15 11:37           ` grahamlab
  0 siblings, 1 reply; 9+ messages in thread
From: Sergei Gavrikov @ 2009-04-15 11:29 UTC (permalink / raw)
  To: grahamlab; +Cc: ecos-discuss

On Wed, Apr 15, 2009 at 03:48:22AM -0700, grahamlab wrote:
> Sergei Gavrikov-4 wrote:
> > 
> > On Wed, Apr 15, 2009 at 02:01:39AM -0700, grahamlab wrote:
> >> 
> >> 
> >> 
> >> Sergei Gavrikov-4 wrote:
> >> > 
> >> > On Tue, Apr 14, 2009 at 03:04:29AM -0700, grahamlab wrote:
> >> >> 
> >> >> Hello everyone
> >> >> I am relatively new to eCos so please forgive me my questions seem
> >> naive.
> >> >> I am developing software targeted at the STM3210e dev board and am
> >> trying
> >> >> to
> >> >> get serial comms going between this board and a program running under
> >> >> ubuntu
> >> >> via virtual box on my PC
> >> >> I have a serial link between the PC and the dev kit (UART1) that uses
> >> >> ttyS0
> >> >> to load the ecos program via gdb. This works, I can download and
> >> execute
> >> >> an
> >> >> eCos program on the Dev board.
> >> >> I have another serial link between my PC and the dev kit (UART2).
> >> >> I have written 2 programs - one using eCos and one to run under
> >> ubuntu.
> >> >> The eCos program opens the /dev/ser1 device and writes a string to
> >> that
> >> >> device and awaits a reply.
> >> >> The ubuntu opens /dev/ttyS1 and waits for a message and then writes
> >> back
> >> >> an
> >> >> acknowledgment.
> >> >> 
> >> >> When these two programs are run I get the following results.
> >> >> 
> >> >> When the ecos program sends its data the ubuntu program receives alot
> >> of
> >> >> data from the Redboot monitor and then the data from the ecos program.
> >> It
> >> >> then blocks on the write. The ecos program has blocked on the read.
> >> >> 
> >> >> Why do I get data from the Redboot monitor and why do both programs
> >> >> block.
> >> >> I have attached both programs 
> >> >> http://www.nabble.com/file/p23036433/hello.cpp hello.cpp ,
> >> >> http://www.nabble.com/file/p23036433/SerialTest.cpp SerialTest.cpp 
> >> >> 
> >> >> Thank you for your time
> >> >> Graham
> >> > 
> >> > Graham, it seems for me, your eCos application quite crashes (board
> >> > resets itself) and you see/get the Redboot's startup screen in your
> >> > program. Your code is terrible, you do not check return-codes!
> >> > 
> >> > hello.cpp:
> >> > while (1) {
> >> >     // ...
> >> >     res = read(fd, buf, 4096);
> >> >     buf[res] = 0;
> >> >     // ...
> >> > }
> >> > 
> >> > SerialTest.cpp:
> >> > while (1) {
> >> >     // ...
> >> >     int             b = read(fd, &buf[0], 4096);
> >> >     buf[b] = '\0';
> >> >     // ...
> >> > }
> >> > 
> >> > How do you think, What will happy on buf[-1] = 0 ? Read about the
> >> return
> >> > values of read(), write().
> >> > 
> >> > man 2 read
> >> > man 2 write
> >> > 
> >> > Your while() blocks are terrible things which will eat all CPU time if
> >> > they will work at all.
> >> > 
> >> > Your hello.cpp is written for PC and that is almost just an echo
> >> > program.  Why do not use terminal program (minicom, hyperterm) at first
> >> > to debug the eCos termios program? It seemed for me that you are not
> >> > only "new" to eCos. Why we took a time to stand up GDB for you? 
> >> > 
> >> > Learn programming, learn C 
> >> > 
> >> > http://en.wikibooks.org/wiki/C_Programming
> >> > 
> >> > Then learn eCos programming.
> >> > 
> >> > 
> >> > Sergei
> >> > 
> >> > -- 
> >> > Before posting, please read the FAQ:
> >> http://ecos.sourceware.org/fom/ecos
> >> > and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
> >> > 
> >> > 
> >> > 
> >> Sergei
> >> I have used the mincom program to receive a test string from ecos
> >> When I use a PC program of my making to read a string I receive data from
> >> redboot before I receive the test string. I do not know why this is the
> >> case
> >> and would appreciate any explanation
> >> 
> >> Graham
> > 
> > On start Redboot (by default) outs own startup screens an both serial
> > channels. You can see it. Run on two consoles
> > 
> > on 1st console:
> > stty speed 38400 -F /dev/ttyS0
> > cat /dev/ttyS0
> > 
> > on 2nd console:
> > stty speed 38400 -F /dev/ttyS1
> > cat /dev/ttyS1
> > 
> > connect cables to the board and then press a Reset button. You will see
> > that data will come on both consoles.
> > 
> > So, when board is reset, Redboot's banner already exists in PC's serial
> > buffer, but that lines has been not read yet (/dev/ttyS1). When you run
> > your PC program, it reads that portion of lines and then it read next
> > incoming data. So, your program should flush serial buffer before to
> > start that read loop.
> > 
> > 
> > Sergei
> > 
> > -- 
> > Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> > and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
> > 
> > 
> > 
> Thanks for the info Sergei
> Will the Redboot banner get output when I start my ecos program. This is
> what seems to be happening
> I flush the serial buffer before reading data in the PC program 
> When I run the PC program it is waiting for input.
> I then run the ecos program and get the redboot stuff in the PC program.

GDB your eCos program step-by-step and find when it crahes and when
board is reset. You have a power -- GDB.

Sergei

-- 
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] 9+ messages in thread

* Re: [ECOS] Serial comms
  2009-04-15 11:29         ` Sergei Gavrikov
@ 2009-04-15 11:37           ` grahamlab
  2009-04-15 12:03             ` Chris Zimman
  0 siblings, 1 reply; 9+ messages in thread
From: grahamlab @ 2009-04-15 11:37 UTC (permalink / raw)
  To: ecos-discuss




Sergei Gavrikov-4 wrote:
> 
> On Wed, Apr 15, 2009 at 03:48:22AM -0700, grahamlab wrote:
>> Sergei Gavrikov-4 wrote:
>> > 
>> > On Wed, Apr 15, 2009 at 02:01:39AM -0700, grahamlab wrote:
>> >> 
>> >> 
>> >> 
>> >> Sergei Gavrikov-4 wrote:
>> >> > 
>> >> > On Tue, Apr 14, 2009 at 03:04:29AM -0700, grahamlab wrote:
>> >> >> 
>> >> >> Hello everyone
>> >> >> I am relatively new to eCos so please forgive me my questions seem
>> >> naive.
>> >> >> I am developing software targeted at the STM3210e dev board and am
>> >> trying
>> >> >> to
>> >> >> get serial comms going between this board and a program running
>> under
>> >> >> ubuntu
>> >> >> via virtual box on my PC
>> >> >> I have a serial link between the PC and the dev kit (UART1) that
>> uses
>> >> >> ttyS0
>> >> >> to load the ecos program via gdb. This works, I can download and
>> >> execute
>> >> >> an
>> >> >> eCos program on the Dev board.
>> >> >> I have another serial link between my PC and the dev kit (UART2).
>> >> >> I have written 2 programs - one using eCos and one to run under
>> >> ubuntu.
>> >> >> The eCos program opens the /dev/ser1 device and writes a string to
>> >> that
>> >> >> device and awaits a reply.
>> >> >> The ubuntu opens /dev/ttyS1 and waits for a message and then writes
>> >> back
>> >> >> an
>> >> >> acknowledgment.
>> >> >> 
>> >> >> When these two programs are run I get the following results.
>> >> >> 
>> >> >> When the ecos program sends its data the ubuntu program receives
>> alot
>> >> of
>> >> >> data from the Redboot monitor and then the data from the ecos
>> program.
>> >> It
>> >> >> then blocks on the write. The ecos program has blocked on the read.
>> >> >> 
>> >> >> Why do I get data from the Redboot monitor and why do both programs
>> >> >> block.
>> >> >> I have attached both programs 
>> >> >> http://www.nabble.com/file/p23036433/hello.cpp hello.cpp ,
>> >> >> http://www.nabble.com/file/p23036433/SerialTest.cpp SerialTest.cpp 
>> >> >> 
>> >> >> Thank you for your time
>> >> >> Graham
>> >> > 
>> >> > Graham, it seems for me, your eCos application quite crashes (board
>> >> > resets itself) and you see/get the Redboot's startup screen in your
>> >> > program. Your code is terrible, you do not check return-codes!
>> >> > 
>> >> > hello.cpp:
>> >> > while (1) {
>> >> >     // ...
>> >> >     res = read(fd, buf, 4096);
>> >> >     buf[res] = 0;
>> >> >     // ...
>> >> > }
>> >> > 
>> >> > SerialTest.cpp:
>> >> > while (1) {
>> >> >     // ...
>> >> >     int             b = read(fd, &buf[0], 4096);
>> >> >     buf[b] = '\0';
>> >> >     // ...
>> >> > }
>> >> > 
>> >> > How do you think, What will happy on buf[-1] = 0 ? Read about the
>> >> return
>> >> > values of read(), write().
>> >> > 
>> >> > man 2 read
>> >> > man 2 write
>> >> > 
>> >> > Your while() blocks are terrible things which will eat all CPU time
>> if
>> >> > they will work at all.
>> >> > 
>> >> > Your hello.cpp is written for PC and that is almost just an echo
>> >> > program.  Why do not use terminal program (minicom, hyperterm) at
>> first
>> >> > to debug the eCos termios program? It seemed for me that you are not
>> >> > only "new" to eCos. Why we took a time to stand up GDB for you? 
>> >> > 
>> >> > Learn programming, learn C 
>> >> > 
>> >> > http://en.wikibooks.org/wiki/C_Programming
>> >> > 
>> >> > Then learn eCos programming.
>> >> > 
>> >> > 
>> >> > Sergei
>> >> > 
>> >> > -- 
>> >> > Before posting, please read the FAQ:
>> >> http://ecos.sourceware.org/fom/ecos
>> >> > and search the list archive:
>> http://ecos.sourceware.org/ml/ecos-discuss
>> >> > 
>> >> > 
>> >> > 
>> >> Sergei
>> >> I have used the mincom program to receive a test string from ecos
>> >> When I use a PC program of my making to read a string I receive data
>> from
>> >> redboot before I receive the test string. I do not know why this is
>> the
>> >> case
>> >> and would appreciate any explanation
>> >> 
>> >> Graham
>> > 
>> > On start Redboot (by default) outs own startup screens an both serial
>> > channels. You can see it. Run on two consoles
>> > 
>> > on 1st console:
>> > stty speed 38400 -F /dev/ttyS0
>> > cat /dev/ttyS0
>> > 
>> > on 2nd console:
>> > stty speed 38400 -F /dev/ttyS1
>> > cat /dev/ttyS1
>> > 
>> > connect cables to the board and then press a Reset button. You will see
>> > that data will come on both consoles.
>> > 
>> > So, when board is reset, Redboot's banner already exists in PC's serial
>> > buffer, but that lines has been not read yet (/dev/ttyS1). When you run
>> > your PC program, it reads that portion of lines and then it read next
>> > incoming data. So, your program should flush serial buffer before to
>> > start that read loop.
>> > 
>> > 
>> > Sergei
>> > 
>> > -- 
>> > Before posting, please read the FAQ:
>> http://ecos.sourceware.org/fom/ecos
>> > and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>> > 
>> > 
>> > 
>> Thanks for the info Sergei
>> Will the Redboot banner get output when I start my ecos program. This is
>> what seems to be happening
>> I flush the serial buffer before reading data in the PC program 
>> When I run the PC program it is waiting for input.
>> I then run the ecos program and get the redboot stuff in the PC program.
> 
> GDB your eCos program step-by-step and find when it crahes and when
> board is reset. You have a power -- GDB.
> 
> Sergei
> 
> -- 
> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
> 
> 
> 
Sergei
I have already done this - no crash occurs
It is a simple program that just writes a string. as soon as the write
operation occurrs I get the redboot banner on the PC program. I get the same
result using the serial2 example program
-- 
View this message in context: http://www.nabble.com/Serial-comms-tp23036433p23057151.html
Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.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] 9+ messages in thread

* RE: [ECOS] Serial comms
  2009-04-15 11:37           ` grahamlab
@ 2009-04-15 12:03             ` Chris Zimman
  2009-04-15 15:44               ` Sergei Gavrikov
  0 siblings, 1 reply; 9+ messages in thread
From: Chris Zimman @ 2009-04-15 12:03 UTC (permalink / raw)
  To: grahamlab, ecos-discuss

[ -- snip -- ]

> Sergei
> I have already done this - no crash occurs
> It is a simple program that just writes a string. as soon as the write
> operation occurrs I get the redboot banner on the PC program. I get the
> same result using the serial2 example program

Guys -- two things here:

(1)  There is absolutely no need to repost the entire previous conversation
every time you reply.  It's just cluttering up the mailing list with rubbish.
Please use a little common sense when deciding how much quoted reply is
necessary.

(2)  This thread in general seems to be of less and less use to the mailing
list with each passing day.  At this point, it seems to have little to do
with eCos itself and more to do with general programming.  If that is indeed
the case, you may want to consider taking this to private email.

--Chris

--
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] 9+ messages in thread

* Re: [ECOS] Serial comms
  2009-04-15 12:03             ` Chris Zimman
@ 2009-04-15 15:44               ` Sergei Gavrikov
  0 siblings, 0 replies; 9+ messages in thread
From: Sergei Gavrikov @ 2009-04-15 15:44 UTC (permalink / raw)
  To: Chris Zimman; +Cc: grahamlab, ecos-discuss

On Wed, Apr 15, 2009 at 07:35:24AM -0400, Chris Zimman wrote:
> [ -- snip -- ]
> 
> > Sergei
> > I have already done this - no crash occurs
> > It is a simple program that just writes a string. as soon as the write
> > operation occurrs I get the redboot banner on the PC program. I get the
> > same result using the serial2 example program
> 
> Guys -- two things here:
> 
> (1)  There is absolutely no need to repost the entire previous conversation
> every time you reply.  It's just cluttering up the mailing list with rubbish.
> Please use a little common sense when deciding how much quoted reply is
> necessary.

Agreed.

> (2)  This thread in general seems to be of less and less use to the mailing
> list with each passing day.  At this point, it seems to have little to do
> with eCos itself and more to do with general programming.  If that is indeed
> the case, you may want to consider taking this to private email.
> 
> --Chris

http://ecos.sourceware.org/intouch.html

ecos-discuss:

A list for general open discussion about eCos. Requests for help and
information are welcome on this list. This is the best starting place
for all eCos users in need of help. All the eCos developers also read
this list.  ecos-patches 	

Chris, if Graham told that he saw U-boot prompt, I would not try to help
him.


Sergei

-- 
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] 9+ messages in thread

end of thread, other threads:[~2009-04-15 12:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-14 10:06 [ECOS] Serial comms grahamlab
2009-04-15  7:24 ` Sergei Gavrikov
2009-04-15  9:26   ` grahamlab
2009-04-15 10:01     ` Sergei Gavrikov
2009-04-15 11:15       ` grahamlab
2009-04-15 11:29         ` Sergei Gavrikov
2009-04-15 11:37           ` grahamlab
2009-04-15 12:03             ` Chris Zimman
2009-04-15 15:44               ` Sergei Gavrikov

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).