EmbDev.net

Forum: ARM programming with GCC/GNU tools syscalls and print


Author: Ed Insam (edinsam)
Posted on:

Rate this post
0 useful
not useful
I have a simple test program that included syscalls.c as follows:

main()
{
  while(1) { printf("OK");
             delay1sec();
             flashLED() // works OK
           }
}


Program compiles and links OK.

My problem is that _write_r() doesn't get called for each character to
be output. The LED flashes every second as it should, but the system
seems to buffer output until about 1000 characters are stored
(internally somewhere), then _write_r() is called to dump the lot in one
go.

All syscalls.c stubs are as per documantations, i.e:

isatty_r() returns 1;
fsatst_r() stores st->st_mode = S_IFCHR; and returns 0;
write_r()
{ for (i = 0; i < len; i++) ser_Out(*p++);
}

ser_Out() is a standard UART output poll routine that has been fully
tested in isolation.


Any ideas what's going on? Are there any global buffer size variables
that need to be checked somewhere?

Thanks in advance

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Ed Insam wrote:
> ...
> Any ideas what's going on? Are there any global buffer size variables
> that need to be checked somewhere?
> ...

Call fflush(stdout) or use the function setvbuf to disable buffering for
stdout. Further information should be available in the newlib's
libc-manual.

Martin Thomas

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 useful
not useful
Also, the text will be output when a newline is emited, so

printf("OK\n") ; will work also.

Clifford

Author: Ed Insam (edinsam)
Posted on:

Rate this post
0 useful
not useful
Martin Thomas wrote:
> Ed Insam wrote:
>> ...
>> Any ideas what's going on? Are there any global buffer size variables
>> that need to be checked somewhere?
>> ...
>
> Call fflush(stdout) or use the function setvbuf to disable buffering for
> stdout. Further information should be available in the newlib's
> libc-manual.
>
> Martin Thomas

Thanks both!

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.