t
Dependencies: DM_FATFileSystem DM_HttpServer DM_USBHost EthernetInterface USBDevice mbed-rpc mbed-rtos
Fork of DMSupport by
Diff: RtosLog.h
- Revision:
- 34:fc366bab393f
- Parent:
- 9:a33326afd686
--- a/RtosLog.h Thu Feb 19 14:41:14 2015 +0100 +++ b/RtosLog.h Mon Mar 09 11:15:56 2015 +0100 @@ -21,6 +21,10 @@ #include "rtos.h" #include "dm_board_config.h" +#if defined(DM_BOARD_USE_USBSERIAL_IN_RTOSLOG) + #include "USBSerial.h" +#endif + /** * All threads can independantly call the printf function in the RtosLog class * without risk of getting the output tangled up. @@ -53,11 +57,40 @@ RtosLog(); ~RtosLog(); - /** Starts the logger thread + /** Starts the logger thread, called from DMBoard::instance().init() */ void init(); + /** Printf that works in an RTOS + * + * This function will create a string from the specified format and + * optional extra arguments and put it into a message that the RtosLog + * thread will write to the log. + * + * Note that if the underlying queue is full then this function + * will block until an entry becomes available. This is required to + * make sure that all printf calls actually get printed. If this happens + * too often then increase the priority of the RtosLog thread or reduce + * the number of printed messages. + * + * @param format format string + * @param ... optional extra arguments + */ int printf(const char* format, ...); + + /** Printf that works in an RTOS + * + * This function will create a string from the specified format and + * optional extra arguments and put it into a message that the RtosLog + * thread will write to the log. + * + * Note that if the underlying queue is full then this function + * discards the message and returns immediately. + * + * @param format format string + * @param ... optional extra arguments + */ + int isr_printf(const char* format, ...); private: @@ -69,7 +102,11 @@ MemoryPool<message_t, NumMessages> _mpool; Queue<message_t, NumMessages> _queue; Semaphore _sem; +#if defined(DM_BOARD_USE_USBSERIAL_IN_RTOSLOG) + USBSerial _serial; +#else Serial _serial; +#endif Thread* _thr; static void logTask(void const* args);