AP_Networking: make lwip debugging easier

This commit is contained in:
Andrew Tridgell 2023-12-07 16:37:56 +11:00
parent f924497194
commit fec0ec79c5
2 changed files with 31 additions and 0 deletions

View File

@ -292,4 +292,31 @@ AP_Networking &network()
}
}
/*
debug printfs from LWIP
*/
int ap_networking_printf(const char *fmt, ...)
{
#ifdef AP_NETWORKING_LWIP_DEBUG_PORT
static AP_HAL::UARTDriver *uart;
if (uart == nullptr) {
uart = hal.serial(AP_NETWORKING_LWIP_DEBUG_PORT);
if (uart == nullptr) {
return -1;
}
uart->begin(921600, 0, 50000);
}
va_list ap;
va_start(ap, fmt);
uart->vprintf(fmt, ap);
va_end(ap);
#else
va_list ap;
va_start(ap, fmt);
hal.console->vprintf(fmt, ap);
va_end(ap);
#endif
return 0;
}
#endif // AP_NETWORKING_ENABLED

View File

@ -319,4 +319,8 @@ namespace AP
AP_Networking &network();
};
extern "C" {
int ap_networking_printf(const char *fmt, ...);
}
#endif // AP_NETWORKING_ENABLED