Skip to content

Commit

Permalink
firmware: app: tasks: Saving PTT packets to the flash memory in the r…
Browse files Browse the repository at this point in the history
…ead EDC task #344 closes #175
  • Loading branch information
mgm8 committed Feb 25, 2024
1 parent dc7b9af commit 7d73203
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions firmware/app/tasks/read_edc.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.9.10
* \version 0.10.9
*
* \date 2020/08/16
*
Expand All @@ -35,8 +35,11 @@

#include <system/sys_log/sys_log.h>
#include <devices/payload/payload.h>
#include <devices/media/media.h>
#include <drivers/edc/edc.h>

#include <structs/satellite.h>

#include "read_edc.h"
#include "startup.h"

Expand All @@ -51,6 +54,8 @@ void vTaskReadEDC(void)
/* Wait startup task to finish */
xEventGroupWaitBits(task_startup_status, TASK_STARTUP_DONE, pdFALSE, pdTRUE, pdMS_TO_TICKS(TASK_READ_EDC_INIT_TIMEOUT_MS));

media_info_t nor_info = media_get_info(MEDIA_NOR);

while(1)
{
TickType_t last_cycle = xTaskGetTickCount();
Expand Down Expand Up @@ -84,11 +89,26 @@ void vTaskReadEDC(void)
uint8_t i = 0;
for(i = 0; i < state.ptt_available; i++)
{
uint8_t ptt_arr[50] = {0};
uint8_t ptt_arr[50] = {0U};
uint32_t ptt_len = 0;

if (payload_get_data(pl_edc_active, PAYLOAD_EDC_PTT, ptt_arr, &ptt_len) == 0)
{
if (media_write(MEDIA_NOR, sat_data_buf.obdh.data.media.last_page_sbcd_pkts * nor_info.page_size, ptt_arr, nor_info.page_size) == 0)
{
sat_data_buf.obdh.data.media.last_page_sbcd_pkts++;

if (sat_data_buf.obdh.data.media.last_page_sbcd_pkts > CONFIG_MEM_SBCD_PKTS_END_PAGE)
{
sat_data_buf.obdh.data.media.last_page_sbcd_pkts = CONFIG_MEM_SBCD_PKTS_START_PAGE;
}
}
else
{
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_READ_EDC_NAME, "Error writing the PTT packet to the flash memory!");
sys_log_new_line();
}

edc_ptt_t ptt = *(edc_ptt_t*)&ptt_arr[0];

sys_log_print_event_from_module(SYS_LOG_INFO, TASK_READ_EDC_NAME, "Received PTT packet:");
Expand Down

0 comments on commit 7d73203

Please sign in to comment.