Fellows, I just faced with a problem which drives me up the wall. I have some sort of RTOS which communiates with external world via uprintf(). I provide 'printing function' which sends data via UART to another MPU. However, I also got some sort of transfer control bits which are responsible for data consistency. So, if any error occures during single byte transfer, all transfers should be terminated. But in our uprintf(), 'func' declared as void and uprintf() does dummy job (sometimes). So, batteries do not live forever then :)
So, I think the problem is the following: The thing was: --------------------------------------------------- The function void uprintf(void (*func)(char c), const char *fmt,...); is similar to "sprintf()", except that caller provides an output function for printing, rather than an output buffer. This function must accept a single "char" parameter, and return "void" (for example to send a character to a UART). The user function is responsible for mutexes, slow interfaces, etc. "uprintf()" will not return until all characters have been printed. --------------------------------------------------- How about changing func defenition to 'int', like: int uprintf(int (*func)(char c), const char *fmt,...); So, if func returns zero, printing continues, otherwise abort with error code stated by 'func'. What do you think? cheers, ~d -- /***************************************************************** ("`-''-/").___..--''"`-._ (\ Dimmy the Wild UA1ACZ `6_ 6 ) `-. ( ).`-.__.`) State Polytechnical Univ. (_Y_.)' ._ ) `._ `. ``-..-' Radio-Physics Departament _..`--'_..-_/ /--'_.' ,' Saint Petersburg, Russia (il),-'' (li),' ((!.-' +7 (812) 5403923, 5585314 *****************************************************************/