WNC14A2A LTE Interface
Dependencies: WncControllerK64F
Fork of WNC14A2AInterface by
WNCDebug.h@10:faa8fe38866b, 2017-09-09 (annotated)
- Committer:
- gie_design
- Date:
- Sat Sep 09 04:50:15 2017 +0000
- Revision:
- 10:faa8fe38866b
- Parent:
- 6:7fd9e590c4e7
Add "fixing virtual destructor warning"
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JMF | 6:7fd9e590c4e7 | 1 | |
JMF | 6:7fd9e590c4e7 | 2 | #ifndef __WNCDEBUG__ |
JMF | 6:7fd9e590c4e7 | 3 | #define __WNCDEBUG__ |
JMF | 6:7fd9e590c4e7 | 4 | #include <stdio.h> |
JMF | 6:7fd9e590c4e7 | 5 | #include "BufferedSerial.h" |
JMF | 6:7fd9e590c4e7 | 6 | |
JMF | 6:7fd9e590c4e7 | 7 | |
JMF | 6:7fd9e590c4e7 | 8 | class WNCDebug |
JMF | 6:7fd9e590c4e7 | 9 | { |
JMF | 6:7fd9e590c4e7 | 10 | public: |
JMF | 6:7fd9e590c4e7 | 11 | WNCDebug( FILE * fd = stderr ): m_puart(NULL) {m_stdiofp=fd;}; |
JMF | 6:7fd9e590c4e7 | 12 | WNCDebug( BufferedSerial * uart): m_stdiofp(NULL) {m_puart=uart;}; |
JMF | 6:7fd9e590c4e7 | 13 | ~WNCDebug() {}; |
JMF | 6:7fd9e590c4e7 | 14 | |
JMF | 6:7fd9e590c4e7 | 15 | int printf( char * fmt, ...) { |
JMF | 6:7fd9e590c4e7 | 16 | char buffer[256]; |
JMF | 6:7fd9e590c4e7 | 17 | int ret=0; |
JMF | 6:7fd9e590c4e7 | 18 | va_list args; |
JMF | 6:7fd9e590c4e7 | 19 | va_start (args, fmt); |
JMF | 6:7fd9e590c4e7 | 20 | vsnprintf(buffer, sizeof(buffer), fmt, args); |
JMF | 6:7fd9e590c4e7 | 21 | if( m_stdiofp ) |
JMF | 6:7fd9e590c4e7 | 22 | ret=fputs(buffer,m_stdiofp); |
JMF | 6:7fd9e590c4e7 | 23 | else |
JMF | 6:7fd9e590c4e7 | 24 | ret=m_puart->puts(buffer); |
JMF | 6:7fd9e590c4e7 | 25 | va_end (args); |
JMF | 6:7fd9e590c4e7 | 26 | return ret; |
JMF | 6:7fd9e590c4e7 | 27 | } |
JMF | 6:7fd9e590c4e7 | 28 | |
JMF | 6:7fd9e590c4e7 | 29 | int putc( int c ) { |
JMF | 6:7fd9e590c4e7 | 30 | int ret=0; |
JMF | 6:7fd9e590c4e7 | 31 | if( m_stdiofp ) |
JMF | 6:7fd9e590c4e7 | 32 | ret=fputc(c, m_stdiofp); |
JMF | 6:7fd9e590c4e7 | 33 | else |
JMF | 6:7fd9e590c4e7 | 34 | ret=m_puart->putc(c); |
JMF | 6:7fd9e590c4e7 | 35 | return ret; |
JMF | 6:7fd9e590c4e7 | 36 | } |
JMF | 6:7fd9e590c4e7 | 37 | |
JMF | 6:7fd9e590c4e7 | 38 | int puts( const char * str ) { |
JMF | 6:7fd9e590c4e7 | 39 | int ret=0; |
JMF | 6:7fd9e590c4e7 | 40 | if( m_stdiofp ) |
JMF | 6:7fd9e590c4e7 | 41 | ret=fputs(str,m_stdiofp); |
JMF | 6:7fd9e590c4e7 | 42 | else |
JMF | 6:7fd9e590c4e7 | 43 | ret=m_puart->puts(str); |
JMF | 6:7fd9e590c4e7 | 44 | return ret; |
JMF | 6:7fd9e590c4e7 | 45 | } |
JMF | 6:7fd9e590c4e7 | 46 | |
JMF | 6:7fd9e590c4e7 | 47 | private: |
JMF | 6:7fd9e590c4e7 | 48 | std::FILE *m_stdiofp; |
JMF | 6:7fd9e590c4e7 | 49 | BufferedSerial *m_puart; |
JMF | 6:7fd9e590c4e7 | 50 | }; |
JMF | 6:7fd9e590c4e7 | 51 | #endif |