public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] [ecos]hanger in printf
@ 2009-02-27 10:57 Robert Brusa
  2009-02-27 11:19 ` Andrew Lunn
  2009-03-13 12:32 ` [ECOS] " Robert Brusa
  0 siblings, 2 replies; 4+ messages in thread
From: Robert Brusa @ 2009-02-27 10:57 UTC (permalink / raw)
  To: ecos-discuss

Hi
Following a recent update (Jan 09) of ecos from V2.0 to the "unstable"  
version and migration to the new gnutools arm-eabi of codesourcery, I run  
into a hanger of a printf statement:

void IsInitMode(void)
{
	static bool first = true;
	static unsigned long int t1, t0 = 0;	// time in units of 10 ms
	t1 = cyg_current_time();
	if ( ( t1 - t0 > 600 * SEC2TICS ) || first) { // msg repeats every minute
		first = false;
		printf("\nstatus is INIT - manual help required");
		t0 = t1;
	}
} //end IsInitMode

No output appears on ser0 or ser1 and a breakpoint at t0 = is never  
reached.

When using diag_printf instead of printf, the message is output on ser1.  
My system is configured to use ser1 for diagnostics. In the earlier  
version, printf-output also appeared on ser1. I have digged somewhat into  
the problem, but no conclusion so far. I can see that the output (should?)  
go to stdiostream. Sometimes later it calls cyg_io_write, but the  
device-handle is zero. A configuration error? - but which? Thanks and  
regards
    Robert

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

* Re: [ECOS] [ecos]hanger in printf
  2009-02-27 10:57 [ECOS] [ecos]hanger in printf Robert Brusa
@ 2009-02-27 11:19 ` Andrew Lunn
  2009-02-27 15:40   ` Robert Brusa
  2009-03-13 12:32 ` [ECOS] " Robert Brusa
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2009-02-27 11:19 UTC (permalink / raw)
  To: Robert Brusa; +Cc: ecos-discuss

On Fri, Feb 27, 2009 at 11:58:05AM +0100, Robert Brusa wrote:
> Hi
> Following a recent update (Jan 09) of ecos from V2.0 to the "unstable"  
> version and migration to the new gnutools arm-eabi of codesourcery, I run 
> into a hanger of a printf statement:
>
> void IsInitMode(void)
> {
> 	static bool first = true;
> 	static unsigned long int t1, t0 = 0;	// time in units of 10 ms
> 	t1 = cyg_current_time();
> 	if ( ( t1 - t0 > 600 * SEC2TICS ) || first) { // msg repeats every minute
> 		first = false;
> 		printf("\nstatus is INIT - manual help required");

Not likely to be your problem, but i would put a trailing \n. printf is buffered, so it won't get
flushed until the buffer is full or \n output. I don't think diag_printf is buffered.

printf() needs a lot of stack space, more than diag_printf. Maybe your
stack is too small?

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

* Re: [ECOS] [ecos]hanger in printf
  2009-02-27 11:19 ` Andrew Lunn
@ 2009-02-27 15:40   ` Robert Brusa
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Brusa @ 2009-02-27 15:40 UTC (permalink / raw)
  To: Andrew Lunn, Robert Brusa; +Cc: ecos-discuss

On Fri, 27 Feb 2009 12:19:25 +0100, Andrew Lunn <andrew@lunn.ch> wrote:

> On Fri, Feb 27, 2009 at 11:58:05AM +0100, Robert Brusa wrote:
>> Hi
>> Following a recent update (Jan 09) of ecos from V2.0 to the "unstable"
>> version and migration to the new gnutools arm-eabi of codesourcery, I  
>> run
>> into a hanger of a printf statement:
>>
>> void IsInitMode(void)
>> {
>> 	static bool first = true;
>> 	static unsigned long int t1, t0 = 0;	// time in units of 10 ms
>> 	t1 = cyg_current_time();
>> 	if ( ( t1 - t0 > 600 * SEC2TICS ) || first) { // msg repeats every  
>> minute
>> 		first = false;
>> 		printf("\nstatus is INIT - manual help required");
>
> Not likely to be your problem, but i would put a trailing \n. printf is  
> buffered, so it won't get
> flushed until the buffer is full or \n output. I don't think diag_printf  
> is buffered.
>
> printf() needs a lot of stack space, more than diag_printf. Maybe your
> stack is too small?
>
>       Andrew

Hi Andrew

replaceing all printf with diag_printf helps. My app. then works, but  
unfortunately
a) diag_printf does not handle floating point numbers and
b) is low level polling. So printf would be more adequate.

Stack: In a task with the statements

			diag_printf(" hei-\n");
			printf("\nheiz:%5.1f %2d\n",te, dcycle);
			diag_printf(" -z\n");

I increased the stack by 500 bytes. Same behaviour - just  hei- comes out  
and nothing else and the app. crashes somewhere in printf.

I think you are right - its indeed a deeply rooted problem of printf. But  
is it a problem of ecos or the (library of the) toolchain I am using? What  
do you think?

    Robert

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

* [ECOS] Re: [ecos]hanger in printf
  2009-02-27 10:57 [ECOS] [ecos]hanger in printf Robert Brusa
  2009-02-27 11:19 ` Andrew Lunn
@ 2009-03-13 12:32 ` Robert Brusa
  1 sibling, 0 replies; 4+ messages in thread
From: Robert Brusa @ 2009-03-13 12:32 UTC (permalink / raw)
  To: ecos-discuss

On Fri, 27 Feb 2009 11:58:05 +0100, Robert Brusa <Bob.Brusa@gmail.com>  
wrote:

> Hi
> Following a recent update (Jan 09) of ecos from V2.0 to the "unstable"  
> version and migration to the new gnutools arm-eabi of codesourcery, I  
> run into a hanger of a printf statement:
>
> void IsInitMode(void)
> {
> 	static bool first = true;
> 	static unsigned long int t1, t0 = 0;	// time in units of 10 ms
> 	t1 = cyg_current_time();
> 	if ( ( t1 - t0 > 600 * SEC2TICS ) || first) { // msg repeats every  
> minute
> 		first = false;
> 		printf("\nstatus is INIT - manual help required");
> 		t0 = t1;
> 	}
> } //end IsInitMode
>
> No output appears on ser0 or ser1 and a breakpoint at t0 = is never  
> reached.
>
> When using diag_printf instead of printf, the message is output on ser1.  
> My system is configured to use ser1 for diagnostics. In the earlier  
> version, printf-output also appeared on ser1. I have digged somewhat  
> into the problem, but no conclusion so far. I can see that the output  
> (should?) go to stdiostream. Sometimes later it calls cyg_io_write, but  
> the device-handle is zero. A configuration error? - but which? Thanks  
> and regards
>     Robert


Hi
well the problem persists. Meanwhile I have found (no, its not the stack!)  
that the thread calling printf crashes somewhere shortly after a call to  
flush_output_unlocked() on line 660 of stream.cxx. ???? Experts - please  
help, this printf involves quite a lot of stuff. I got the impression,  
that something (the stream?) is locked, although its not clear why. Could  
it be that it never succeeds unlocking and hence the thread gets blocked?
    Robert

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

end of thread, other threads:[~2009-03-13  9:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-27 10:57 [ECOS] [ecos]hanger in printf Robert Brusa
2009-02-27 11:19 ` Andrew Lunn
2009-02-27 15:40   ` Robert Brusa
2009-03-13 12:32 ` [ECOS] " Robert Brusa

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