Fixed setting in canbus
This commit is contained in:
parent
ade514cbf3
commit
1a85b40444
|
|
@ -13,9 +13,27 @@ LOG_MODULE_REGISTER(canbus, CONFIG_LOG_CAN_LEVEL);
|
|||
|
||||
static int canbus_set(const char *key, size_t len, settings_read_cb read_cb, void *cb_arg)
|
||||
{
|
||||
const char *next;
|
||||
int rc;
|
||||
|
||||
// Handle setting values for CAN bus configuration
|
||||
LOG_DBG("Setting CAN bus configuration: key=%s, len=%zu", key, len);
|
||||
// Implement the logic to set the CAN bus configuration based on the key and value
|
||||
if (settings_name_steq(key, "node_id", &next) && next != NULL)
|
||||
{
|
||||
if (len != sizeof(node_id))
|
||||
{
|
||||
LOG_ERR("Invalid length for node_id setting: %zu", len);
|
||||
return -EINVAL; // Invalid argument
|
||||
}
|
||||
|
||||
int rc = read_cb(cb_arg, &node_id, sizeof(node_id));
|
||||
if (rc < 0)
|
||||
{
|
||||
LOG_ERR("Failed to read node_id setting: %d", rc);
|
||||
return rc; // Read error
|
||||
}
|
||||
LOG_DBG("Set CAN bus node ID to: %d", node_id);
|
||||
}
|
||||
return 0; // Return 0 on success
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +65,9 @@ int canbus_init(void)
|
|||
LOG_ERR("Failed to save default CAN bus node id: %d", rc);
|
||||
return rc;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = settings_load_one("canbus/node_id", &node_id, sizeof(node_id));
|
||||
if (rc < 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue