Skip to content

Commit

Permalink
firmware: app: tasks: param_server: Adding OBDH communication handling
Browse files Browse the repository at this point in the history
  • Loading branch information
andrempmattos committed Aug 2, 2021
1 parent a9f1c2d commit 93b0a54
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 33 deletions.
107 changes: 76 additions & 31 deletions firmware/app/tasks/param_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* \author Gabriel Mariano Marcelino <[email protected]>
* \author André M. P. de Mattos <[email protected]>
*
* \version 0.2.6
* \version 0.2.8
*
* \date 2021/07/24
*
Expand Down Expand Up @@ -66,46 +66,91 @@ void vTaskParamServer(void *pvParameters)
/* Process interrupt from UART ISR. */
if ( (ulNotifiedValue & NOTIFICATION_VALUE_FROM_I2C_ISR) != 0)
{
/* TO DO. */
if (obdh_decode(&adr, &val, &cmd))
{
sys_log_print_event_from_module(SYS_LOG_INFO, TASK_PARAM_SERVER_NAME, "OBDH command received: ");
sys_log_print_msg("cmd=");
sys_log_print_int(cmd);
sys_log_new_line();

switch(cmd)
{
case OBDH_COMMAND_WRITE:
if (eps_buffer_write(adr, &val) != 0)
{
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 (obdh_answer(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();
}
}
break;
default:
break;
}
}
else
{
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_PARAM_SERVER_NAME, "The received OBDH command was corrupted!");
sys_log_new_line();
}
}

/* Process interrupt from UART ISR. */
if ( (ulNotifiedValue & NOTIFICATION_VALUE_FROM_UART_ISR) != 0)
{
ttc_decode(&adr, &val, &cmd);

sys_log_print_event_from_module(SYS_LOG_INFO, TASK_PARAM_SERVER_NAME, "TTC command received: ");
sys_log_print_msg("cmd=");
sys_log_print_int(cmd);
sys_log_new_line();

switch(cmd)
if (ttc_decode(&adr, &val, &cmd))
{
case TTC_COMMAND_WRITE:
if (eps_buffer_write(adr, &val) != 0)
{
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)
{
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_PARAM_SERVER_NAME, "TTC read command has failed to complete!");
sys_log_new_line();
}
else
{
if (ttc_answer(adr, val) != 0)
sys_log_print_event_from_module(SYS_LOG_INFO, TASK_PARAM_SERVER_NAME, "TTC command received: ");
sys_log_print_msg("cmd=");
sys_log_print_int(cmd);
sys_log_new_line();

switch(cmd)
{
case TTC_COMMAND_WRITE:
if (eps_buffer_write(adr, &val) != 0)
{
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_PARAM_SERVER_NAME, "TTC read command has failed to complete!");
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;
default:
break;
break;
case TTC_COMMAND_READ:
if (eps_buffer_read(adr, &val) != 0)
{
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_PARAM_SERVER_NAME, "TTC read command has failed to complete (buffer)!");
sys_log_new_line();
}
else
{
if (ttc_answer(adr, val) != 0)
{
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_PARAM_SERVER_NAME, "TTC read command has failed to complete (answer)!");
sys_log_new_line();
}
}
break;
default:
break;
}
}
else
{
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_PARAM_SERVER_NAME, "The received TTC command was corrupted!");
sys_log_new_line();
}
}
}
else
Expand Down
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.7
* \version 0.2.8
*
* \date 2020/10/21
*
Expand All @@ -36,7 +36,7 @@
#ifndef VERSION_H_
#define VERSION_H_

#define FIRMWARE_VERSION "0.2.7"
#define FIRMWARE_VERSION "0.2.8"

#define FIRMWARE_STATUS "Development"

Expand Down

0 comments on commit 93b0a54

Please sign in to comment.