Busreader: wait for message

This commit is contained in:
Martijn Scheepers
2025-04-30 12:19:38 +02:00
parent 18b13291cd
commit a584d46849
4 changed files with 33 additions and 46 deletions

View File

@@ -1,41 +1,8 @@
#pragma once
// #include "FreeRTOS.h"
// #include "task.h"
// #include <stdio.h>
// #include "hardware/timer.h"
// #include <string.h>
// /* Define a variable to hold the initial timer count. */
// static uint32_t start_time;
// /* Configure Timer 1 to generate the runtime statistics counter. */
// extern "C" void configureTimerForRunTimeStats(void)
// {
// /* Store the initial count of the microsecond timer. */
// start_time = time_us_32();
// }
// /* Get the current value of the runtime counter. */
// extern "C" unsigned long getRunTimeCounterValue(void)
// {
// /* Return the elapsed time in microseconds since start_time. */
// return time_us_32() - start_time;
// }
// extern "C" unsigned long ulMainGetRunTimeCounterValue() {
// return rp2040.getCycleCount64();
// }
// void configureTimerForRunTimeStats();
// uint32_t getRunTimeCounterValue();
class Debug
{
public:
// static void configureTimerForRunTimeStats();
// static uint32_t getRunTimeCounterValue();
static void showRunTimeStats();
static void showTaskList();
static void showHeapStats();

View File

@@ -23,18 +23,8 @@ void BusReader::busReaderTask(__unused void *pvParameters)
while (1)
{
uint32_t ulNotifiedValue;
if (xTaskNotifyWait(pdFALSE, ULONG_MAX, &ulNotifiedValue, 0) == pdPASS)
{
if ((ulNotifiedValue & CARD_READY_BIT_0) != 0)
{
printf("Card Ready notify\n");
Global::credentialRequest.cardReady = true;
}
}
std::vector<uint8_t> *data;
if (xQueueReceive(RS485::message_queue, &data, 0))
if (xQueueReceive(RS485::message_queue, &data, portMAX_DELAY))
{
// printf("RX: ");
// for (size_t i = 0; i < data->size(); i++)
@@ -47,6 +37,35 @@ void BusReader::busReaderTask(__unused void *pvParameters)
delete data;
}
// uint32_t ulNotifiedValue;
// if (xTaskNotifyWait(pdFALSE, ULONG_MAX, &ulNotifiedValue, 0) == pdPASS)
// {
// if ((ulNotifiedValue & CARD_READY_BIT_0) != 0)
// {
// printf("Card Ready notify\n");
// Global::credentialRequest.cardReady = true;
// }
// }
// std::vector<uint8_t> *data;
// if (xQueueReceive(RS485::message_queue, &data, 0))
// {
// // printf("RX: ");
// // for (size_t i = 0; i < data->size(); i++)
// // {
// // printf("0x%02X-", data->data()[i]);
// // }
// // printf("\r\n");
// parseMessage(&Global::credentialRequest, data);
// delete data;
// }
taskYIELD();
}
}

View File

@@ -60,7 +60,8 @@ void CardReader::cardReaderTask(__unused void *pvParameters)
if (checkCard(&Global::credentialRequest) == true)
{
printf("----- Card read oke -----\n");
xTaskNotify(BusReader::busReaderTaskHandle, CARD_READY_BIT_0, eSetValueWithOverwrite);
//xTaskNotify(BusReader::busReaderTaskHandle, CARD_READY_BIT_0, eSetValueWithOverwrite);
Global::credentialRequest.cardReady = true;
}
else
{

View File

@@ -11,7 +11,7 @@ void Debug::showRunTimeStats()
configRUN_TIME_COUNTER_TYPE ulTotalRunTime, ulStatsAsPercentage;
volatile UBaseType_t arraySize = uxTaskGetNumberOfTasks();
TaskStatus_t *tasks = (TaskStatus_t *)pvPortMalloc(arraySize * sizeof(TaskStatus_t));
TaskStatus_t *tasks = (TaskStatus_t *)pvPortMalloc(arraySize * sizeof(TaskStatus_t));
arraySize = uxTaskGetSystemState(tasks, arraySize, &ulTotalRunTime);
printf("Task Name\t\tRun Time\tCPU %%\n");