IRPyro messaging application
Communications program between IRPyro and IRPyro evaluation tool

Process a stream of bytes to find a valid GUI command. More...

Collaboration diagram for Message Unpack:

Data Structures

struct  command_table
 

Macros

#define CMD_BUFFER_SIZE   20
 
#define PAYLOAD_SIZE   7
 

Enumerations

enum  decode_state_type { initialize, get_payload, error_report, complete }
 

Functions

static void assign_cmd_code (void)
 on valid crc assigns cmd_code More...
 
static uint8_t byte_get (uint8_t *output_byte)
 gets a byte from the UART or the byte array More...
 
static void decode_result_assign (void)
 evaluates the result More...
 
static void fn_decode_complete (void)
 sets the completion flag and the next state More...
 
static void fn_decode_error_report (void)
 sets the error flag More...
 
static void fn_decode_initialize (void)
 On success returns a buffer with command and payload (if any) More...
 
static void fn_decode_payload_get (void)
 fills the payload buffer if the command requires it More...
 
decode_result_type message_unpack_decode (void)
 FSM to decode a received command If the command is valid, the command code and the payload (if any) are made available for the caller function. More...
 
void message_unpack_result (uint8_t *cmd_code_result, uint8_t *sensor_destination, uint8_t *cmd_payload)
 gives access to the command code and the corresponding payload (if any) More...
 
static void payload_get (uint8_t *payload, uint8_t const *cmd_buffer, uint8_t cmd_tab_idx)
 gets the payload from a command buffer array coming from the GUI More...
 
static void process_next_byte (void)
 gets the next byte to process More...
 
static void process_stream (void)
 process stream until crc checks or fails More...
 
static void search_for_command (void)
 looks for a command in the byte stream More...
 

Variables

uint8_t cmd_buffer [CMD_BUFFER_SIZE] = {0}
 
uint8_t cmd_completed
 
uint8_t cmd_empty
 
uint8_t cmd_error
 
uint8_t cmd_input
 
uint8_t cmd_search_result
 
uint8_t continue_process_stream
 
uint8_t crc_calc
 
uint8_t get_char_result
 
uint8_t idx_buffer
 
static const struct command_table IRPyro_cmd [CMD_LIST_SIZE]
 
uint8_t max_reads
 
decode_state_type next_state
 
decode_result_type op_result
 
uint8_t payload_array [PAYLOAD_SIZE] = {0}
 

Detailed Description

Process a stream of bytes to find a valid GUI command.

*
* 
Note

Macro Definition Documentation

◆ CMD_BUFFER_SIZE

#define CMD_BUFFER_SIZE   20

Definition at line 141 of file message_unpack.c.

◆ PAYLOAD_SIZE

#define PAYLOAD_SIZE   7

Definition at line 142 of file message_unpack.c.

Enumeration Type Documentation

◆ decode_state_type

Enumerator
initialize 
get_payload 
error_report 
complete 

Definition at line 66 of file message_unpack.c.

Function Documentation

◆ assign_cmd_code()

static void assign_cmd_code ( void  )
static

on valid crc assigns cmd_code

Definition at line 178 of file message_unpack.c.

Here is the caller graph for this function:

◆ byte_get()

static uint8_t byte_get ( uint8_t *  output_byte)
static

gets a byte from the UART or the byte array

Definition at line 159 of file message_unpack.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decode_result_assign()

static void decode_result_assign ( void  )
static

evaluates the result

Definition at line 348 of file message_unpack.c.

Here is the caller graph for this function:

◆ fn_decode_complete()

static void fn_decode_complete ( void  )
static

sets the completion flag and the next state

Returns
cmd_completed state machine end flag
next_state index for the state machine

Definition at line 326 of file message_unpack.c.

Here is the caller graph for this function:

◆ fn_decode_error_report()

static void fn_decode_error_report ( void  )
static

sets the error flag

Returns
cmd_error error flag
next_state index for the state machine

Definition at line 316 of file message_unpack.c.

Here is the caller graph for this function:

◆ fn_decode_initialize()

static void fn_decode_initialize ( void  )
static

On success returns a buffer with command and payload (if any)

Returns
cmd_search_result code for the command currently in process
cmd_buffer segment of the current byte stream with command and payload
next_state index for the state machine

Definition at line 255 of file message_unpack.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fn_decode_payload_get()

static void fn_decode_payload_get ( void  )
static

fills the payload buffer if the command requires it

Returns
payload payload buffer
next_state index for the state machine

Definition at line 303 of file message_unpack.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ message_unpack_decode()

decode_result_type message_unpack_decode ( void  )

FSM to decode a received command If the command is valid, the command code and the payload (if any) are made available for the caller function.

Definition at line 365 of file message_unpack.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ message_unpack_result()

void message_unpack_result ( uint8_t *  cmd_code_result,
uint8_t *  sensor_destination,
uint8_t *  cmd_payload 
)

gives access to the command code and the corresponding payload (if any)

Returns
cmd_code_result command processed successfully
cmd_payload corresponding payload (if any)

Definition at line 336 of file message_unpack.c.

Here is the caller graph for this function:

◆ payload_get()

static void payload_get ( uint8_t *  payload,
uint8_t const *  cmd_buffer,
uint8_t  cmd_tab_idx 
)
static

gets the payload from a command buffer array coming from the GUI

Parameters
[out]payloaddestination of cmd_buffer payload
[in]cmd_buffersource byte array being decoded
[in]cmd_tab_idxrecovers the payload size from the look

Definition at line 284 of file message_unpack.c.

Here is the caller graph for this function:

◆ process_next_byte()

static void process_next_byte ( void  )
static

gets the next byte to process

Definition at line 194 of file message_unpack.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_stream()

static void process_stream ( void  )
static

process stream until crc checks or fails

Definition at line 210 of file message_unpack.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_for_command()

static void search_for_command ( void  )
static

looks for a command in the byte stream

Definition at line 239 of file message_unpack.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ cmd_buffer

uint8_t cmd_buffer[CMD_BUFFER_SIZE] = {0}

Definition at line 146 of file message_unpack.c.

◆ cmd_completed

uint8_t cmd_completed

Definition at line 143 of file message_unpack.c.

◆ cmd_empty

uint8_t cmd_empty

Definition at line 143 of file message_unpack.c.

◆ cmd_error

uint8_t cmd_error

Definition at line 143 of file message_unpack.c.

◆ cmd_input

uint8_t cmd_input

Definition at line 144 of file message_unpack.c.

◆ cmd_search_result

uint8_t cmd_search_result

Definition at line 145 of file message_unpack.c.

◆ continue_process_stream

uint8_t continue_process_stream

Definition at line 152 of file message_unpack.c.

◆ crc_calc

uint8_t crc_calc

Definition at line 151 of file message_unpack.c.

◆ get_char_result

uint8_t get_char_result

Definition at line 148 of file message_unpack.c.

◆ idx_buffer

uint8_t idx_buffer

Definition at line 149 of file message_unpack.c.

◆ IRPyro_cmd

const struct command_table IRPyro_cmd[CMD_LIST_SIZE]
static

Definition at line 1 of file message_unpack.c.

◆ max_reads

uint8_t max_reads

Definition at line 150 of file message_unpack.c.

◆ next_state

decode_state_type next_state

Definition at line 154 of file message_unpack.c.

◆ op_result

decode_result_type op_result

Definition at line 153 of file message_unpack.c.

◆ payload_array

uint8_t payload_array[PAYLOAD_SIZE] = {0}

Definition at line 147 of file message_unpack.c.