Commit 782ebe29 authored by Rahix's avatar Rahix
Browse files

Merge 'Improve error logging'

- hw-lock: Log task names and return address when lock is busy
- pmic: print strerror(errno)


See merge request !221
parents 0a535cf0 e2557f81
......@@ -25,13 +25,25 @@ int hwlock_acquire(enum hwlock_periph p, TickType_t wait)
if (p >= _HWLOCK_MAX) {
return -EINVAL;
}
TaskHandle_t task = xTaskGetCurrentTaskHandle();
if (xSemaphoreTake(hwlock_mutex[p], wait) != pdTRUE) {
LOG_WARN("hwlock", "Lock %u is busy.", p);
LOG_WARN(
"hwlock",
"Lock %u is busy, held by: %s, attempt to accquire by: %s",
p,
pcTaskGetName(hwlock_tasks[p]),
pcTaskGetName(task)
);
LOG_DEBUG(
"hwlock",
"...attempted to lock from pc %p",
__builtin_return_address(0)
);
return -EBUSY;
}
hwlock_tasks[p] = xTaskGetCurrentTaskHandle();
hwlock_tasks[p] = task;
return 0;
}
......
......@@ -16,6 +16,7 @@
#include "timers.h"
#include <stdio.h>
#include <string.h>
/* Task ID for the pmic handler */
static TaskHandle_t pmic_task_id = NULL;
......@@ -207,7 +208,10 @@ static void pmic_check_battery()
res = pmic_read_amux(PMIC_AMUX_BATT_U, &u_batt);
if (res < 0) {
LOG_ERR("pmic", "Failed reading battery voltage: %d", res);
LOG_ERR("pmic",
"Failed reading battery voltage: %s (%d)",
strerror(-res),
res);
return;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment