-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Firmware: app: task: payload: Adding Payload X initialization and rea…
…d tasks #337
- Loading branch information
1 parent
bf96476
commit 51d5942
Showing
5 changed files
with
169 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* read_px.c | ||
* | ||
* Copyright The OBDH 2.0 Contributors. | ||
* | ||
* This file is part of OBDH 2.0. | ||
* | ||
* OBDH 2.0 is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* OBDH 2.0 is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with OBDH 2.0. If not, see <http:/\/www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
/** | ||
* \brief Read PX task implementation. | ||
* | ||
* \author Augusto Cezar Boldori Vassoler <[email protected]> | ||
* | ||
* \version 0.0.1 | ||
* | ||
* \date 2023/08/28 | ||
* | ||
* \addtogroup read_px | ||
* \{ | ||
*/ | ||
|
||
#include <system/sys_log/sys_log.h> | ||
#include <devices/payload/payload.h> | ||
#include <drivers/px/px.h> | ||
|
||
#include "read_px.h" | ||
#include "startup.h" | ||
|
||
xTaskHandle xTaskReadPXHandle; | ||
|
||
pl_px_buf_t px_buf = {0}; | ||
|
||
void vTaskReadPX(void) | ||
{ | ||
static payload_t pl_px_active = PAYLOAD_X; | ||
px_buf.lenth = PX_PONG_BUF_SIZE; | ||
|
||
/* Wait startup task to finish */ | ||
xEventGroupWaitBits(task_startup_status, TASK_STARTUP_DONE, pdFALSE, pdTRUE, pdMS_TO_TICKS(TASK_READ_PX_INIT_TIMEOUT_MS)); | ||
|
||
while(1) | ||
{ | ||
TickType_t last_cycle = xTaskGetTickCount(); | ||
|
||
/* Read data */ | ||
if (payload_get_data(pl_px_active, PAYLOAD_X_PONG, px_buf.buffer, &px_buf.length) != 0) | ||
{ | ||
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_READ_PX_NAME, "Error reading the ping-pong data!"); | ||
sys_log_new_line(); | ||
} | ||
else | ||
{ | ||
sys_log_print_event_from_module(SYS_LOG_INFO, TASK_READ_PX_NAME, "Received Payload X packet:"); | ||
sys_log_new_line(); | ||
|
||
uint8_t i = 0; | ||
for(i=0;i<px_buf.length;i++){ | ||
sys_log_print_uint(px_buf.buffer[i]); | ||
} | ||
|
||
} | ||
|
||
vTaskDelayUntil(&last_cycle, pdMS_TO_TICKS(TASK_READ_PX_PERIOD_MS)); | ||
} | ||
} | ||
|
||
/** \} End of read_px group */ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* read_px.h | ||
* | ||
* Copyright The OBDH 2.0 Contributors. | ||
* | ||
* This file is part of OBDH 2.0. | ||
* | ||
* OBDH 2.0 is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* OBDH 2.0 is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with OBDH 2.0. If not, see <http:/\/www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
/** | ||
* \brief Read PX task implementation. | ||
* | ||
* \author Augusto Cezar Boldori Vassoler <[email protected]> | ||
* | ||
* \version 0.0.1 | ||
* | ||
* \date 2023/08/28 | ||
* | ||
* \addtogroup read_px | ||
* \{ | ||
*/ | ||
|
||
#ifndef READ_PX_H_ | ||
#define READ_PX_H_ | ||
|
||
#include <FreeRTOS.h> | ||
#include <task.h> | ||
|
||
#define TASK_READ_PX_NAME "PX Task" /**< Task name. */ | ||
#define TASK_READ_PX_STACK_SIZE 300 /**< Stack size in bytes. */ | ||
#define TASK_READ_PX_PRIORITY 3 /**< Task priority. */ | ||
#define TASK_READ_PX_PERIOD_MS (60000) /**< Task period in milliseconds. */ | ||
#define TASK_READ_PX_INIT_TIMEOUT_MS 2000 /**< Wait time to initialize the task in milliseconds. */ | ||
|
||
#define PX_PONG_BUF_SIZE 4; /**< Size of pong response message. */ | ||
/** | ||
* \brief PX data type. | ||
*/ | ||
typedef struct | ||
{ | ||
uint8_t buffer[30]; | ||
uint32_t length; | ||
} pl_px_buf_t; | ||
|
||
/** | ||
* \brief PX read data buffer. | ||
*/ | ||
extern pl_px_buf_t px_buf; | ||
|
||
/** | ||
* \brief Read PX handle. | ||
*/ | ||
extern xTaskHandle xTaskReadPXHandle; | ||
|
||
/** | ||
* \brief Read PX task. | ||
* | ||
* \return None. | ||
*/ | ||
void vTaskReadPX(void); | ||
|
||
#endif /* READ_PX_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters