CANBus alarm monitoring after bus recovery
Posted: Mon May 31, 2021 9:21 am
we are using the can interface, idf 3.3.5 release version.
We have a seperate recovery task to get CAN alerts ant to recover from BUS_OFF. Basically we followed the recovery example, contained in the idf.
we are get the alerts properly (eg if we shorten the bus for a short moment), also the bus recovers propperly from bus of by calling the function can_initiate_recovery().
Our problem is that the event "CAN_ALERT_BUS_ERROR" is only working until the first occurence of a bus recovery. After the first recovery, the system does not report alerts like CAN_ALERT_BUS_ERROR anymore.
Reading the counters by using can_get_status_info() sows the same: info.bus_error_count counts up in case of a bus error, but after a bus-recover the counter of bus_error_count stays at its last value before the recovery happened.
A reconfiguring of the needed alerts after a bus recovery does not help.
What is wrong? Why stays the bus error counter at its position when a bus off occures and the bus recovers (and stays there till a complete restart?)
thanks for your help.
Juergen
Code snippet:
void can_recovery_task(void *arg)
{
ESP_LOGI(tag, "Starting CAN recovery task");
while(1)
{
uint32_t alerts=0;
can_read_alerts(&alerts, portMAX_DELAY);
ESP_LOGI(tag, "---Alert Read: -- : %04x", alerts);
if (alerts & CAN_ALERT_ABOVE_ERR_WARN)
{
ESP_LOGI(tag, "Surpassed Error Warning Limit");
}
if (alerts & CAN_ALERT_ERR_PASS)
{
ESP_LOGI(tag, "Entered Error Passive state");
}
if (alerts & CAN_ALERT_ERR_ACTIVE)
{
ESP_LOGI(tag, "Entered Can Error Active");
}
if (alerts & CAN_ALERT_BUS_ERROR)
{
ESP_LOGI(tag, "Entered Alert Bus Error");
}
if (alerts & CAN_ALERT_BUS_OFF)
{
ESP_LOGE(tag, "Bus Off --> Initiate bus recovery");
can_initiate_recovery(); //Needs 128 occurrences of bus free signal
vTaskDelay(pdMS_TO_TICKS(1000));
}
if (alerts & CAN_ALERT_BUS_RECOVERED)
{
//Bus recovery was successful
// only for testing. Does not help !!
esp_err_t res = can_reconfigure_alerts(ALERTS_ENABLED, NULL);
ESP_LOGI(tag, "Bus Recovered %d--> restarting Can", res);
//put can in start state again and re-enable alert monitoring
can_start();
}
}
}
We have a seperate recovery task to get CAN alerts ant to recover from BUS_OFF. Basically we followed the recovery example, contained in the idf.
we are get the alerts properly (eg if we shorten the bus for a short moment), also the bus recovers propperly from bus of by calling the function can_initiate_recovery().
Our problem is that the event "CAN_ALERT_BUS_ERROR" is only working until the first occurence of a bus recovery. After the first recovery, the system does not report alerts like CAN_ALERT_BUS_ERROR anymore.
Reading the counters by using can_get_status_info() sows the same: info.bus_error_count counts up in case of a bus error, but after a bus-recover the counter of bus_error_count stays at its last value before the recovery happened.
A reconfiguring of the needed alerts after a bus recovery does not help.
What is wrong? Why stays the bus error counter at its position when a bus off occures and the bus recovers (and stays there till a complete restart?)
thanks for your help.
Juergen
Code snippet:
void can_recovery_task(void *arg)
{
ESP_LOGI(tag, "Starting CAN recovery task");
while(1)
{
uint32_t alerts=0;
can_read_alerts(&alerts, portMAX_DELAY);
ESP_LOGI(tag, "---Alert Read: -- : %04x", alerts);
if (alerts & CAN_ALERT_ABOVE_ERR_WARN)
{
ESP_LOGI(tag, "Surpassed Error Warning Limit");
}
if (alerts & CAN_ALERT_ERR_PASS)
{
ESP_LOGI(tag, "Entered Error Passive state");
}
if (alerts & CAN_ALERT_ERR_ACTIVE)
{
ESP_LOGI(tag, "Entered Can Error Active");
}
if (alerts & CAN_ALERT_BUS_ERROR)
{
ESP_LOGI(tag, "Entered Alert Bus Error");
}
if (alerts & CAN_ALERT_BUS_OFF)
{
ESP_LOGE(tag, "Bus Off --> Initiate bus recovery");
can_initiate_recovery(); //Needs 128 occurrences of bus free signal
vTaskDelay(pdMS_TO_TICKS(1000));
}
if (alerts & CAN_ALERT_BUS_RECOVERED)
{
//Bus recovery was successful
// only for testing. Does not help !!
esp_err_t res = can_reconfigure_alerts(ALERTS_ENABLED, NULL);
ESP_LOGI(tag, "Bus Recovered %d--> restarting Can", res);
//put can in start state again and re-enable alert monitoring
can_start();
}
}
}