Index: MessageSupport.c =================================================================== diff -u -rf77e7c2b1dab61807f21f25c793afc063d43907c -rfb1be94d30e7017deb9bb465ce676ee37f2d73f3 --- MessageSupport.c (.../MessageSupport.c) (revision f77e7c2b1dab61807f21f25c793afc063d43907c) +++ MessageSupport.c (.../MessageSupport.c) (revision fb1be94d30e7017deb9bb465ce676ee37f2d73f3) @@ -25,14 +25,13 @@ /*********************************************************************//** * @brief - * The broadcastData function queues a broadcast message for transmission - * to a given CAN buffer. - * @details \b Inputs: none - * @details \b Outputs: broadcast data msg constructed and queued - * @param msgID ID of message to broadcast - * @param buffer ID of CAN transmit buffer to add broadcast message to - * @param dataPtr pointer to the start of the serialized message data to queue - * @param length length of the serialized message data + * The broadcastData function queues a broadcast message for transmission. + * @details Inputs: none + * @details Outputs: broadcast data msg constructed and queued for transmission. + * @param msgID message ID of the data message to broadcast + * @param buffer comm buffer ID + * @param dataPtr pointer to the start of the payload data buffer + * @param length number of bytes of data in the given data buffer * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastData( MSG_ID_T msgID, COMM_BUFFER_T buffer, U08* dataPtr, U32 length ) @@ -57,4 +56,37 @@ return result; } +/*********************************************************************//** + * @brief + * The sendMessage function queues a cmd/resp message for transmission. + * @details Inputs: none + * @details Outputs: Message constructed and queued for transmission. + * @param msgID message ID of the message to broadcast + * @param buffer comm buffer ID + * @param dataPtr pointer to the start of the payload data buffer + * @param length number of bytes of data in the given data buffer + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendMessage( MSG_ID_T msgID, COMM_BUFFER_T buffer, U08* dataPtr, U32 length ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = (U16)msgID; + msg.hdr.payloadLen = (U08)length; + + if ( ( length > 0 ) && ( length < BITS_8_FULL_SCALE ) && ( dataPtr != 0 ) ) + { + memcpy( payloadPtr, dataPtr, length ); + } + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, buffer, ACK_REQUIRED ); + + return result; +} + /**@}*/