instrument tx timings for watchdog analysis
This commit is contained in:
22
src/main.cpp
22
src/main.cpp
@@ -339,12 +339,19 @@ static bool send_batch_payload(const uint8_t *data, size_t len, uint32_t ts_for_
|
||||
write_u16_le(&payload[4], static_cast<uint16_t>(len));
|
||||
memcpy(&payload[BATCH_HEADER_SIZE], data + offset, chunk_len);
|
||||
|
||||
watchdog_kick();
|
||||
uint32_t tx_start = millis();
|
||||
bool ok = lora_send(pkt);
|
||||
uint32_t tx_ms = millis() - tx_start;
|
||||
all_ok = all_ok && ok;
|
||||
if (!ok) {
|
||||
note_fault(g_sender_faults, g_sender_last_error, g_sender_last_error_utc, g_sender_last_error_ms, FaultType::LoraTx);
|
||||
display_set_last_error(g_sender_last_error, g_sender_last_error_utc, g_sender_last_error_ms);
|
||||
}
|
||||
if (SERIAL_DEBUG_MODE && tx_ms > 500) {
|
||||
serial_debug_printf("tx: chunk %u/%u took %lums ok=%u", static_cast<unsigned>(i + 1),
|
||||
static_cast<unsigned>(chunk_count), static_cast<unsigned long>(tx_ms), ok ? 1 : 0);
|
||||
}
|
||||
offset += chunk_len;
|
||||
delay(10);
|
||||
}
|
||||
@@ -391,22 +398,37 @@ static bool send_inflight_batch(uint32_t ts_for_display) {
|
||||
if (!g_inflight_active || g_inflight_count == 0) {
|
||||
return false;
|
||||
}
|
||||
uint32_t json_start = millis();
|
||||
String json;
|
||||
if (!meterBatchToJson(g_inflight_samples, g_inflight_count, g_inflight_batch_id, json, &g_sender_faults, g_sender_last_error)) {
|
||||
return false;
|
||||
}
|
||||
uint32_t json_ms = millis() - json_start;
|
||||
if (SERIAL_DEBUG_MODE) {
|
||||
serial_debug_printf("tx: batch_id=%u count=%u json_len=%u", g_inflight_batch_id, g_inflight_count, static_cast<unsigned>(json.length()));
|
||||
if (json_ms > 200) {
|
||||
serial_debug_printf("tx: json encode took %lums", static_cast<unsigned long>(json_ms));
|
||||
}
|
||||
serial_debug_print_json(json);
|
||||
}
|
||||
|
||||
static uint8_t compressed[BATCH_MAX_COMPRESSED];
|
||||
size_t compressed_len = 0;
|
||||
uint32_t compress_start = millis();
|
||||
if (!compressBuffer(reinterpret_cast<const uint8_t *>(json.c_str()), json.length(), compressed, sizeof(compressed), compressed_len)) {
|
||||
return false;
|
||||
}
|
||||
uint32_t compress_ms = millis() - compress_start;
|
||||
if (SERIAL_DEBUG_MODE && compress_ms > 200) {
|
||||
serial_debug_printf("tx: compress took %lums", static_cast<unsigned long>(compress_ms));
|
||||
}
|
||||
|
||||
uint32_t send_start = millis();
|
||||
bool ok = send_batch_payload(compressed, compressed_len, ts_for_display, g_inflight_batch_id);
|
||||
uint32_t send_ms = millis() - send_start;
|
||||
if (SERIAL_DEBUG_MODE && send_ms > 1000) {
|
||||
serial_debug_printf("tx: send batch took %lums", static_cast<unsigned long>(send_ms));
|
||||
}
|
||||
if (ok) {
|
||||
g_last_batch_send_ms = millis();
|
||||
serial_debug_printf("tx: sent batch_id=%u len=%u", g_inflight_batch_id, static_cast<unsigned>(compressed_len));
|
||||
|
||||
Reference in New Issue
Block a user