chprintf and finite timeout Topic is solved

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
Post Reply
tsichevski
Posts: 35
Joined: Fri Feb 09, 2018 12:44 am
Has thanked: 2 times
Been thanked: 5 times

chprintf and finite timeout

Post 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
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: chprintf and finite timeout

Post 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
tsichevski
Posts: 35
Joined: Fri Feb 09, 2018 12:44 am
Has thanked: 2 times
Been thanked: 5 times

Re: chprintf and finite timeout

Post by tsichevski »

Thank you, Giovanni.

Can I reset both the queues from an ordinary task, not from an interrupt?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: chprintf and finite timeout

Post by Giovanni »

Hi,

You can reset from task or interrupt.

Giovanni
Post Reply