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]

Re: Serial comms




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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]