Skip to content

Commit

Permalink
Update main.c
Browse files Browse the repository at this point in the history
  • Loading branch information
meatpiHQ committed Dec 13, 2024
1 parent d715873 commit 017f8a4
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,21 @@ static void can_rx_task(void *pvParameters)
// ESP_LOGI(TAG, "bvoltage: %f", bvoltage);
// }
process_led(0);
if(esp_timer_get_time() - time_old > 1000*1000)
{
uint32_t free_heap = heap_caps_get_free_size(HEAP_CAPS);
time_old = esp_timer_get_time();
// ESP_LOGI(TAG, "free_heap: %lu", free_heap);
// ESP_LOGI(TAG, "msg %u/sec", num_msg);
// num_msg = 0;
}
// static uint32_t min_heap = UINT32_MAX;
// static uint32_t max_heap = 0;
// uint32_t free_heap = heap_caps_get_free_size(HEAP_CAPS);

// // Track min/max on every loop iteration
// min_heap = (free_heap < min_heap) ? free_heap : min_heap;
// max_heap = (free_heap > max_heap) ? free_heap : max_heap;

// // Print only every second
// if(esp_timer_get_time() - time_old > 1000*1000)
// {
// time_old = esp_timer_get_time();
// ESP_LOGI(TAG, "heap current: %lu min: %lu max: %lu", free_heap, min_heap, max_heap);
// }

while(can_receive(&rx_msg, 0) == ESP_OK)
{
// num_msg++;
Expand Down Expand Up @@ -296,7 +303,10 @@ static void can_rx_task(void *pvParameters)
else if(protocol == OBD_ELM327 || protocol == AUTO_PID)
{
// Let elm327.c decide which messages to process
xQueueSend( xmsg_obd_rx_queue, ( void * ) &rx_msg, pdMS_TO_TICKS(0) );
if(elm327_ready_to_receive())
{
xQueueSend( xmsg_obd_rx_queue, ( void * ) &rx_msg, pdMS_TO_TICKS(0) );
}
}

if(ucTCP_TX_Buffer.usLen != 0)
Expand Down Expand Up @@ -596,5 +606,6 @@ void app_main(void)
// esp_log_level_set("autopid_parser", ESP_LOG_ERROR);
// esp_log_level_set("autopid_task", ESP_LOG_ERROR);
// esp_log_level_set("elm327_process_cmd", ESP_LOG_ERROR);
// esp_log_level_set("can_rx_task", ESP_LOG_INFO);
}

0 comments on commit 017f8a4

Please sign in to comment.