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,
|
||||
|
||||
@@ -22,7 +22,10 @@ static std::vector<net_frame_callback> frame_callbacks;
|
||||
|
||||
void net_send_raw(std::span<const uint8_t> data) {
|
||||
dlog_if_slow("net_send_raw", 1000, [&]{
|
||||
w6300::send(raw_socket, data);
|
||||
auto result = w6300::send(raw_socket, data);
|
||||
if (!result)
|
||||
dlogf("w6300 send failed: %zu bytes, err %d",
|
||||
data.size(), static_cast<int>(result.error()));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ static void start_ping_rate(const responder& resp, uint16_t target,
|
||||
ping_rate_send_one(st);
|
||||
net_add_frame_callback(*cb);
|
||||
|
||||
st->timer = dispatch_schedule_ms(60000, [st]() {
|
||||
st->timer = dispatch_schedule_ms(10000, [st]() {
|
||||
uint32_t elapsed_us = time_us_32() - st->start_us;
|
||||
char msg[64];
|
||||
snprintf(msg, sizeof(msg), "timeout after %u/%u rt in %lu ms",
|
||||
|
||||
Reference in New Issue
Block a user