modified to get more signal info
Dependencies: WncControllerK64F
Fork of WNC14A2AInterface by
Diff: WNCDebug.h
- Revision:
- 6:7fd9e590c4e7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WNCDebug.h Wed Apr 19 15:19:05 2017 +0000 @@ -0,0 +1,51 @@ + +#ifndef __WNCDEBUG__ +#define __WNCDEBUG__ +#include <stdio.h> +#include "BufferedSerial.h" + + +class WNCDebug +{ +public: + WNCDebug( FILE * fd = stderr ): m_puart(NULL) {m_stdiofp=fd;}; + WNCDebug( BufferedSerial * uart): m_stdiofp(NULL) {m_puart=uart;}; + ~WNCDebug() {}; + + int printf( char * fmt, ...) { + char buffer[256]; + int ret=0; + va_list args; + va_start (args, fmt); + vsnprintf(buffer, sizeof(buffer), fmt, args); + if( m_stdiofp ) + ret=fputs(buffer,m_stdiofp); + else + ret=m_puart->puts(buffer); + va_end (args); + return ret; + } + + int putc( int c ) { + int ret=0; + if( m_stdiofp ) + ret=fputc(c, m_stdiofp); + else + ret=m_puart->putc(c); + return ret; + } + + int puts( const char * str ) { + int ret=0; + if( m_stdiofp ) + ret=fputs(str,m_stdiofp); + else + ret=m_puart->puts(str); + return ret; + } + +private: + std::FILE *m_stdiofp; + BufferedSerial *m_puart; +}; +#endif \ No newline at end of file