Skip to content

Commit

Permalink
firmware: app: tasks: param_server: Updating the implementation #136
Browse files Browse the repository at this point in the history
  • Loading branch information
mgm8 committed Dec 2, 2021
1 parent deee7c6 commit 614e2a6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
52 changes: 27 additions & 25 deletions firmware/app/tasks/param_server.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* param_server.h
*
* Copyright (C) 2021, SpaceLab.
* Copyright The EPS 2.0 Contributors.
*
* This file is part of EPS 2.0.
*
Expand All @@ -16,7 +16,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EPS 2.0. If not, see <http://www.gnu.org/licenses/>.
* along with EPS 2.0. If not, see <http:/\/www.gnu.org/licenses/>.
*
*/

Expand All @@ -26,7 +26,7 @@
* \author Gabriel Mariano Marcelino <[email protected]>
* \author André M. P. de Mattos <[email protected]>
*
* \version 0.2.30
* \version 0.2.41
*
* \date 2021/07/24
*
Expand All @@ -37,6 +37,8 @@
#include <system/sys_log/sys_log.h>
#include <structs/eps2_data.h>

#include <drivers/i2c_slave/i2c_slave.h>

#include <devices/ttc/ttc.h>
#include <devices/obdh/obdh.h>

Expand All @@ -47,24 +49,24 @@ xTaskHandle xTaskParamServerHandle;

void vTaskParamServer(void *pvParameters)
{
BaseType_t xResult;
uint32_t ulNotifiedValue;

uint8_t adr = 0;
uint32_t val = 0;
uint8_t cmd = 0;
BaseType_t result;
uint32_t notified_value;

/* Wait startup task to finish */
xEventGroupWaitBits(task_startup_status, TASK_STARTUP_DONE, pdFALSE, pdTRUE, pdMS_TO_TICKS(TASK_PARAM_SERVER_INIT_TIMEOUT_MS));

while(1)
{
xResult = xTaskNotifyWait(0UL, 0xFFFFFFFFUL, &ulNotifiedValue, pdMS_TO_TICKS(TASK_PARAM_SERVER_MAX_BLOCK_TIME_MS));
result = xTaskNotifyWait(0UL, 0xFFFFFFFFUL, &notified_value, pdMS_TO_TICKS(TASK_PARAM_SERVER_MAX_BLOCK_TIME_MS));

uint8_t adr = 0;
uint32_t val = 0;
uint8_t cmd = 0;

if (xResult == pdPASS)
if (result == pdPASS)
{
/* Process interrupt from UART ISR. */
if ( (ulNotifiedValue & NOTIFICATION_VALUE_FROM_I2C_ISR) != 0)
/* Process interrupt from I2C ISR. */
if ((notified_value & I2C_SLAVE_NOTI_VAL_TO_I2C_RX_ISR) != 0)
{
if (obdh_decode(&adr, &val, &cmd) == 0)
{
Expand All @@ -81,21 +83,23 @@ void vTaskParamServer(void *pvParameters)
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_PARAM_SERVER_NAME, "OBDH write command has failed to complete!");
sys_log_new_line();
}

break;
case OBDH_COMMAND_READ:
if (eps_buffer_read(adr, &val) != 0)
{
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_PARAM_SERVER_NAME, "OBDH read command has failed to complete (buffer)!");
sys_log_new_line();
}
else
if (eps_buffer_read(adr, &val) == 0)
{
if (obdh_answer(adr, val) != 0)
if (obdh_write_output_buffer(adr, val) != 0)
{
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_PARAM_SERVER_NAME, "OBDH read command has failed to complete (answer)!");
sys_log_new_line();
}
}
else
{
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_PARAM_SERVER_NAME, "OBDH read command has failed to complete (buffer)!");
sys_log_new_line();
}

break;
default:
break;
Expand All @@ -107,9 +111,7 @@ void vTaskParamServer(void *pvParameters)
sys_log_new_line();
}
}

/* Process interrupt from UART ISR. */
if ( (ulNotifiedValue & NOTIFICATION_VALUE_FROM_UART_ISR) != 0)
else if ((notified_value & NOTIFICATION_VALUE_FROM_UART_ISR) != 0)
{
if (ttc_decode(&adr, &val, &cmd) == 0)
{
Expand All @@ -126,6 +128,7 @@ void vTaskParamServer(void *pvParameters)
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_PARAM_SERVER_NAME, "TTC write command has failed to complete!");
sys_log_new_line();
}

break;
case TTC_COMMAND_READ:
if (eps_buffer_read(adr, &val) != 0)
Expand All @@ -141,6 +144,7 @@ void vTaskParamServer(void *pvParameters)
sys_log_new_line();
}
}

break;
default:
break;
Expand All @@ -159,8 +163,6 @@ void vTaskParamServer(void *pvParameters)
sys_log_print_event_from_module(SYS_LOG_WARNING, TASK_PARAM_SERVER_NAME, "Any command request received in the last minute");
sys_log_new_line();
}


}
}

Expand Down
1 change: 1 addition & 0 deletions firmware/devices/obdh/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# OBDH Device
4 changes: 2 additions & 2 deletions firmware/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.2.40
* \version 0.2.41
*
* \date 2020/10/21
*
Expand All @@ -36,7 +36,7 @@
#ifndef VERSION_H_
#define VERSION_H_

#define FIRMWARE_VERSION "0.2.40"
#define FIRMWARE_VERSION "0.2.41"

#define FIRMWARE_STATUS "Development"

Expand Down

0 comments on commit 614e2a6

Please sign in to comment.