diff --git a/src/N2kStream.cpp b/src/N2kStream.cpp index 4f7e5a7..179c795 100644 --- a/src/N2kStream.cpp +++ b/src/N2kStream.cpp @@ -72,12 +72,16 @@ size_t N2kStream::print(int val, uint8_t radix) { return print(ptr); } +size_t N2kStream::println(void) { + return print("\r\n"); +} + size_t N2kStream::println(const char *str) { - return print(str) + print("\r\n"); + return print(str) + println(); } size_t N2kStream::println(int val, uint8_t radix) { - return print(val, radix) + print("\r\n"); + return print(val, radix) + println(); } #endif diff --git a/src/N2kStream.h b/src/N2kStream.h index d186062..8bc10dd 100644 --- a/src/N2kStream.h +++ b/src/N2kStream.h @@ -105,6 +105,14 @@ class N2kStream { */ size_t print(int val, uint8_t radix = 10); + /***********************************************************************//** + * \brief Print newline to stream. + * + * \param str String data for the stream + * \return size_t + */ + size_t println(void); + /***********************************************************************//** * \brief Print string and newline to stream. * diff --git a/src/NMEA2000.cpp b/src/NMEA2000.cpp index 6ae4a13..74d6a48 100644 --- a/src/NMEA2000.cpp +++ b/src/NMEA2000.cpp @@ -29,12 +29,14 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include -#define DebugStream Serial +// #define DebugStream Serial // outputs debug messages to the serial console (only for Arduino) +#define DebugStream (*ForwardStream) // outputs debug messages to same destination as ForwardStream // #define NMEA2000_FRAME_ERROR_DEBUG // #define NMEA2000_FRAME_IN_DEBUG // #define NMEA2000_FRAME_OUT_DEBUG -// #define NMEA2000_MSG_DEBUG +// #define NMEA2000_MSG_TX_DEBUG +// #define NMEA2000_MSG_RX_DEBUG // This one spams the console with every parsed message // #define NMEA2000_BUF_DEBUG // #define NMEA2000_DEBUG @@ -68,7 +70,7 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # define N2kFrameOutDbgln(fmt, args...) #endif -#if defined(NMEA2000_MSG_DEBUG) +#if defined(NMEA2000_MSG_TX_DEBUG) # define N2kMsgDbgStart(fmt, args...) DebugStream.print(N2kMillis()); DebugStream.print(": "); DebugStream.print (fmt , ## args) # define N2kMsgDbg(fmt, args...) DebugStream.print (fmt , ## args) # define N2kMsgDbgln(fmt, args...) DebugStream.println (fmt , ## args) @@ -78,6 +80,16 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # define N2kMsgDbgln(fmt, args...) #endif +#if defined(NMEA2000_MSG_RX_DEBUG) +# define N2kMsgRxDbgStart(fmt, args...) DebugStream.print(N2kMillis()); DebugStream.print(": "); DebugStream.print (fmt , ## args) +# define N2kMsgRxDbg(fmt, args...) DebugStream.print (fmt , ## args) +# define N2kMsgRxDbgln(fmt, args...) DebugStream.println (fmt , ## args) +#else +# define N2kMsgRxDbgStart(fmt, args...) +# define N2kMsgRxDbg(fmt, args...) +# define N2kMsgRxDbgln(fmt, args...) +#endif + #if defined(NMEA2000_BUF_DEBUG) # define DbgPrintBuf(len, buf, addln) PrintBuf(&DebugStream, len, buf, addln) #else @@ -2032,7 +2044,7 @@ uint8_t tNMEA2000::SetN2kCANBufMsg(unsigned long canId, unsigned char len, unsig ); MsgIndex++); if (MsgIndex