diff --git a/FluidNC/src/Motors/TrinamicUartDriver.cpp b/FluidNC/src/Motors/TrinamicUartDriver.cpp index 369bb126d..97ac24729 100644 --- a/FluidNC/src/Motors/TrinamicUartDriver.cpp +++ b/FluidNC/src/Motors/TrinamicUartDriver.cpp @@ -21,10 +21,7 @@ namespace MotorDrivers { void TrinamicUartDriver::init() { _uart = config->_uarts[_uart_num]; - if (!_uart) { - log_error("TMC Driver missing uart" << _uart_num << " section"); - return; - } + Assert(_uart, "TMC Driver missing uart%d section", _uart_num); _cs_pin.setAttr(Pin::Attr::Output); } diff --git a/FluidNC/src/Pin.cpp b/FluidNC/src/Pin.cpp index 01c606f6c..5e22afacf 100644 --- a/FluidNC/src/Pin.cpp +++ b/FluidNC/src/Pin.cpp @@ -12,7 +12,6 @@ #include "Pins/I2SOPinDetail.h" #include "Pins/ErrorPinDetail.h" #include "string_util.h" -#include // snprintf() Pins::PinDetail* Pin::undefinedPin = new Pins::VoidPinDetail(); Pins::PinDetail* Pin::errorPin = new Pins::ErrorPinDetail("unknown"); @@ -113,9 +112,7 @@ Pin Pin::create(std::string_view str) { } } catch (const AssertionFailed& ex) { // We shouldn't get here under normal circumstances. log_error("ERR: " << str << " - " << ex.what()); - char buf[255]; - snprintf(buf, 255, "ERR: %s - %s", str, ex.what()); - Assert(false, buf); + Assert(false, ""); // return Pin(new Pins::ErrorPinDetail(str.str())); } } diff --git a/FluidNC/src/Pins/DebugPinDetail.cpp b/FluidNC/src/Pins/DebugPinDetail.cpp index 63e72d236..7bac835e6 100644 --- a/FluidNC/src/Pins/DebugPinDetail.cpp +++ b/FluidNC/src/Pins/DebugPinDetail.cpp @@ -5,28 +5,15 @@ #include "../UartChannel.h" #include // millis() -#include // vsnprintf -#include namespace Pins { - inline void WriteSerial(const char* format, ...) { - char buf[50]; - va_list arg; - va_list copy; - va_start(arg, format); - va_copy(copy, arg); - size_t len = vsnprintf(buf, 50, format, arg); - va_end(copy); - log_msg_to(Uart0, buf); - va_end(arg); - } // I/O: void DebugPinDetail::write(int high) { if (high != int(_isHigh)) { _isHigh = bool(high); if (shouldEvent()) { - WriteSerial("Write %s < %d", toString(), high); + log_msg_to(Uart0, "Write " << toString() << " < " << high); } } _implementation->write(high); @@ -35,7 +22,7 @@ namespace Pins { int DebugPinDetail::read() { auto result = _implementation->read(); if (shouldEvent()) { - WriteSerial("Read %s > %d", toString(), result); + log_msg_to(Uart0, "Read " << toString() << " > " << result); } return result; } @@ -63,10 +50,10 @@ namespace Pins { if (value.has(PinAttributes::InitialOn)) { buf[n++] = '+'; } - buf[n++] = 0; + buf[n++] = '\0'; if (shouldEvent()) { - WriteSerial("Set pin attr %s = %s", toString(), buf); + log_msg_to(Uart0, "Set pin attr " << toString() << " = " << buf); } _implementation->setAttr(value); } @@ -76,7 +63,7 @@ namespace Pins { void DebugPinDetail::CallbackHandler::handle(void* arg) { auto handler = static_cast(arg); if (handler->_myPin->shouldEvent()) { - WriteSerial("Received ISR on %s", handler->_myPin->toString()); + log_msg_to(Uart0, "Received ISR on " << handler->_myPin->toString()); } handler->callback(handler->argument); } @@ -88,7 +75,7 @@ namespace Pins { _isrHandler.callback = callback; if (shouldEvent()) { - WriteSerial("Attaching interrupt to pin %s, mode %d", toString(), mode); + log_msg_to(Uart0, "Attaching interrupt to pin " << toString() << ", mode " << mode); } _implementation->attachInterrupt(_isrHandler.handle, &_isrHandler, mode); } @@ -109,7 +96,7 @@ namespace Pins { } else if (_eventCount == 10) { _lastEvent = time; ++_eventCount; - WriteSerial("Suppressing events..."); + log_msg_to(Uart0, "Suppressing events..."); return false; } else { _lastEvent = time;