Page 1 of 1

chprintf and finite timeout  Topic is solved

Posted: Mon Dec 10, 2018 2:21 pm
by tsichevski
Hi,

is it possible to use finite timeouts with chprintf()? I use this function to emit data to a serial line, which may asynchronously disconnect in the middle of the call, in which case my task hangs forever :(

Regards,
Vladimir

Re: chprintf and finite timeout

Posted: Mon Dec 10, 2018 2:45 pm
by Giovanni
Hi,

It is not currently possible, it would require changes because chprintf() prints on a stream (BaseSequentialStream) and streams don't have timeouts.

You could consider the normal printf() and provide your output function with timeout, this is compiler-dependent however. I will look into changes for chprintf() but this could take a while.

Moving this topic under "change requests".

BTW, you could reset the serial driver output queue, it would be released.

Giovanni

Re: chprintf and finite timeout

Posted: Mon Dec 10, 2018 3:47 pm
by tsichevski
Thank you, Giovanni.

Can I reset both the queues from an ordinary task, not from an interrupt?

Re: chprintf and finite timeout

Posted: Mon Dec 10, 2018 6:23 pm
by Giovanni
Hi,

You can reset from task or interrupt.

Giovanni