/************************************************************************** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file MsgQueues.h * * @date 08-Oct-2019 * @author S. Nash * * @brief header file for Message Queues service . * **************************************************************************/ #ifndef __MSG_QUEUES_H__ #define __MSG_QUEUES_H__ #include "../HDCommon.h" // ********** public definitions ********** #define MAX_MSG_PAYLOAD_SIZE 100 // bytes typedef enum Msg_Queues { MSG_Q_IN = 0, NUM_OF_MSG_QUEUES } MSG_QUEUE_T; #pragma pack(push,1) typedef struct { #ifndef ACK_NOT_IMPLEMENTED S16 seqNo; // sequence # (and ACK required bit) of message #endif U16 msgID; // ID of message U08 payloadLen; // length of payload in bytes } MESSAGE_HEADER_T; typedef struct { MESSAGE_HEADER_T hdr; // message header U08 payload[ MAX_MSG_PAYLOAD_SIZE ]; // message payload } MESSAGE_T; typedef struct { MESSAGE_T msg; // message U08 crc; // message CRC } MESSAGE_WRAPPER_T; #pragma pack(pop) #define MESSAGE_OVERHEAD_SIZE (sizeof(MESSAGE_HEADER_T) + sizeof(U08)) // ********** public function prototypes ********** void initMsgQueues( void ); BOOL addToMsgQueue( MSG_QUEUE_T queue, MESSAGE_WRAPPER_T *msg ); BOOL getFromMsgQueue( MSG_QUEUE_T queue, MESSAGE_WRAPPER_T *msg ); BOOL isMsgQueueEmpty( MSG_QUEUE_T queue ); BOOL isMsgQueueFull( MSG_QUEUE_T queue ); void blankMessage( MESSAGE_T *message ); void blankMessageInWrapper( MESSAGE_WRAPPER_T *message ); #endif