![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
dac subsystem
log/log.cpp@1:8056d0c97ee2, 2014-04-01 (annotated)
- Committer:
- dzl5187
- Date:
- Tue Apr 01 04:47:27 2014 +0000
- Revision:
- 1:8056d0c97ee2
- Parent:
- 0:c7adfe979a5b
first commit;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dzl5187 | 0:c7adfe979a5b | 1 | #include "log.h" |
dzl5187 | 0:c7adfe979a5b | 2 | #include "stdio.h" |
dzl5187 | 0:c7adfe979a5b | 3 | #include "mbed.h" |
dzl5187 | 0:c7adfe979a5b | 4 | #include "stdarg.h" |
dzl5187 | 0:c7adfe979a5b | 5 | Serial pc(USBTX, USBRX); |
dzl5187 | 0:c7adfe979a5b | 6 | void vlogMessage(const char *,va_list); |
dzl5187 | 0:c7adfe979a5b | 7 | /** |
dzl5187 | 0:c7adfe979a5b | 8 | Function: logMessage |
dzl5187 | 0:c7adfe979a5b | 9 | Description: output the message(can be formatted string) to PC |
dzl5187 | 0:c7adfe979a5b | 10 | */ |
dzl5187 | 0:c7adfe979a5b | 11 | void logMessage(const char *fmt,...){ |
dzl5187 | 0:c7adfe979a5b | 12 | va_list args; |
dzl5187 | 0:c7adfe979a5b | 13 | va_start(args, fmt); |
dzl5187 | 0:c7adfe979a5b | 14 | vlogMessage( fmt, args ); |
dzl5187 | 0:c7adfe979a5b | 15 | va_end(args); |
dzl5187 | 0:c7adfe979a5b | 16 | } |
dzl5187 | 0:c7adfe979a5b | 17 | |
dzl5187 | 0:c7adfe979a5b | 18 | void vlogMessage(const char *fmt,va_list args){ |
dzl5187 | 0:c7adfe979a5b | 19 | char buffer[255]; |
dzl5187 | 0:c7adfe979a5b | 20 | char msg[255]; |
dzl5187 | 0:c7adfe979a5b | 21 | //get time stamp |
dzl5187 | 0:c7adfe979a5b | 22 | sprintf(buffer, "Time[seconds]: %.3f : ", programTimer.read_ms()/1000.0); |
dzl5187 | 0:c7adfe979a5b | 23 | |
dzl5187 | 0:c7adfe979a5b | 24 | vsprintf( msg, fmt, args ); |
dzl5187 | 0:c7adfe979a5b | 25 | strcat( buffer, msg); |
dzl5187 | 0:c7adfe979a5b | 26 | pc.printf("%s \n", buffer); |
dzl5187 | 0:c7adfe979a5b | 27 | } |