Add debug logging to overflow/error paths, fix pipeline=2 drop
This commit is contained in:
@@ -26,7 +26,9 @@ void dispatch_init() {
|
||||
}
|
||||
|
||||
timer_handle dispatch_schedule_ms(uint32_t ms, std::function<void()> fn) {
|
||||
return timers.schedule_ms(ms, std::move(fn));
|
||||
auto h = timers.schedule_ms(ms, std::move(fn));
|
||||
if (!h) dlogf("timer alloc failed: %lu ms", static_cast<unsigned long>(ms));
|
||||
return h;
|
||||
}
|
||||
|
||||
bool dispatch_cancel_timer(timer_handle h) {
|
||||
@@ -45,7 +47,10 @@ bool dispatch_cancel_timer(timer_handle h) {
|
||||
|
||||
auto dispatch_msg = [&](const DecodedMessage& msg, std::function<void(std::span<const uint8_t>)> send) {
|
||||
auto it = handler_map.find(msg.type_id);
|
||||
if (it == handler_map.end()) return;
|
||||
if (it == handler_map.end()) {
|
||||
dlogf("dispatch: unknown type_id %d", msg.type_id);
|
||||
return;
|
||||
}
|
||||
responder resp{msg.message_id, std::move(send)};
|
||||
it->second(resp, msg.payload);
|
||||
};
|
||||
@@ -79,8 +84,10 @@ bool dispatch_cancel_timer(timer_handle h) {
|
||||
|
||||
dispatch_msg(*msg, [&](std::span<const uint8_t> data) {
|
||||
if (data.size() <= usb.tx.free()) {
|
||||
usb.send(data);
|
||||
if (!usb.send(data))
|
||||
dlogf("usb send failed: %zu bytes, %u free", data.size(), usb.tx.free());
|
||||
} else {
|
||||
dlogf("usb response too large: %zu bytes, %u free", data.size(), usb.tx.free());
|
||||
uint8_t err_buf[256];
|
||||
span_writer err_out(err_buf, sizeof(err_buf));
|
||||
auto err = encode_response_into(err_out, msg->message_id,
|
||||
|
||||
Reference in New Issue
Block a user