#include "stream.h" /* * * Dataflow Status Enumeration * * This typedef governs the dataflow state machine. Enums should be self explanatory * * TODO Handle other DF pathways for slave RX datapoint and slave RX command * * |------------+-----+----------------------------------------+---------------------+-------------------------| * | Status | Int | Status Invariant | Action | Next Status | * |------------+-----+----------------------------------------+---------------------+-------------------------| * | DF_IDLE | 0 | Ready to send m2s_SOR | Send m2s_SOR | DF_RX_DOC or ??? | * | DF_RX_DOC | 1 | Sent m2s_SOR; ready to receive s2m_DOC | Receive s2m_DOC | DF_CTS | * | DF_CTS | 2 | Received m2s_SOR; ready to send DF_CTS | Send m2s_CTS | DF_RX_DATA or DF_RX_CMD | * | DF_RX_DATA | 3 | Sent m2s_CTS; receive s2m_data | Receive s2m_data | DF_SUCCESS | * | DF_RX_CMD | 4 | sent m2s_CTS receive s2m_command | Receive s2m_command | DF_SUCCESS | * |------------+-----+----------------------------------------+---------------------+-------------------------| * * */ typedef enum SOR_codes { SLAVE_TX = 1, SLAVE_RX_DATAPOINT = 2, SLAVE_RX_COMMAND = 3 } SOR_codes_t; typedef enum DOC_codes { CMD_UNICAST = 0x1, CMD_MULTICAST = 0x2, CMD_BROADCAST = 0x3, RESERVED = 0x4, DATA = 0x5 } DOC_codes_t; #define EXPAND_AS_ENUM(a, b) a, #define EXPAND_AS_JUMPTABLE(a, b) b, #define EXPAND_DF_PROTOTYPES(a, b) int b(p_stream_t, void**); #define DF_STATE_TABLE(ENTRY) \ ENTRY(DF_IDLE, DF_func_idle) \ ENTRY(DF_RX_DOC, DF_func_rx_doc) \ ENTRY(DF_TX_CTS, DF_func_tx_cts) \ ENTRY(DF_RX_DATA, DF_func_rx_data) \ ENTRY(DF_RX_CMD, DF_func_rx_cmd) \ ENTRY(DF_TX_DATA, DF_func_tx_data) \ ENTRY(DF_TX_CMD, DF_func_tx_cmd) typedef enum dataflow_states { DF_STATE_TABLE(EXPAND_AS_ENUM) NUM_DF_STATES, DF_FAIL, DF_SUCCESS, DF_STATE_FAIL, DF_STATE_SUCCESS, } dataflow_states_t; typedef int (*df_func_t)(p_stream_t, void**); DF_STATE_TABLE(EXPAND_DF_PROTOTYPES);