SCOM Serial Communication Protocol  0.5.2
Macros | Functions
scom_service.c File Reference

Service utilities. More...

#include "hal.h"
#include "scom_service.h"
#include "scom_service_filter.h"
#include "scom_frame.h"
#include <string.h>

Go to the source code of this file.

Macros

#define HAL_LOG_CHANNEL   SCOM
 
#define HAL_LOG_SUBCHANNEL   SERVICE
 

Functions

SCOMResult SCOM_SendServiceFrame (SCOMDataLink scom, uint8_t framePriority, uint8_t serviceID, uint8_t primitiveID, const void *frameData, uint8_t frameDataSize)
 
SCOMResult SCOM_SendServiceMultiFrame (SCOMDataLink scom, uint8_t framePriority, uint8_t serviceID, uint8_t primitiveID, const void *frameData, uint32_t frameDataSize, SCOMMultiFrameDesc *multiFrameDesc)
 
SCOMResult SCOM_ServiceTransaction (SCOMDataLink scom, const uint8_t framePriority, const uint8_t serviceID, const uint8_t primitiveID, const void *const txData, const uint8_t txDataSize, void *rxData, const size_t rxDataSize)
 

Detailed Description

Service utilities.

License: $License$
Version
Revision
448
Purpose: SCOM serial communication protocol

Definition in file scom_service.c.

Macro Definition Documentation

#define HAL_LOG_CHANNEL   SCOM

Definition at line 10 of file scom_service.c.

#define HAL_LOG_SUBCHANNEL   SERVICE

Definition at line 11 of file scom_service.c.

Function Documentation

SCOMResult SCOM_SendServiceFrame ( SCOMDataLink  scom,
uint8_t  framePriority,
uint8_t  serviceID,
uint8_t  primitiveID,
const void *  frameData,
uint8_t  frameDataSize 
)

Schedules the service frame transmission. The frame is copied (along with all the data) to the internal SCOM buffer. If there is no activity on the hardware interface then the frame will be sent at the next call to SCOM_Proc. However if there are other frames (older or with higher priority) the frame will wait for it's turn. This function may be called asynchronously with other SCOM functions and from ISRs.

Parameters
scomSCOM handle
framePrioritypriority of a frame
serviceIDservice ID
primitiveIDprimitive ID
frameDatadata associated with the frame or NULL if there is no data
frameDataSizesize of data to be associated with frame
Returns
SCOM_RESULT_OK if the frame was scheduled successfully or SCOM_TX_FRAME_BUFFER_OVERRUN if there is no more free space to buffer the frame

Definition at line 22 of file scom_service.c.

References SCOMFrameQueueItem::frame, SCOMDataLinkDesc::frameBuffer, HAL_PACKED::payload, SCOM_ERROR, SCOM_FRAME_TX_READY_FOR_SEND, SCOM_RESULT_OK, SCOM_SOF_CHARACTER, SCOM_TX_FRAME_BUFFER_OVERRUN, SCOMFrame_SetPriority(), SCOMFrameQueue_Insert(), SCOMFrameQueue_Lock(), HAL_PACKED::serviceframe, HAL_PACKED::sof, SCOMFrameQueueItem::state, and SCOMFrameBuffer::txFrameQueue.

Referenced by SCOM_ServiceTransaction().

SCOMResult SCOM_SendServiceMultiFrame ( SCOMDataLink  scom,
uint8_t  framePriority,
uint8_t  serviceID,
uint8_t  primitiveID,
const void *  frameData,
uint32_t  frameDataSize,
SCOMMultiFrameDesc multiFrameDesc 
)

Schedules sending of another part of multi-frame service packet. The resulting frame is copied (along with all the data) to the internal SCOM buffer, just like in the case of a standard SCOM frame.

Parameters
scomSCOM handle
framePrioritypriority of a frame
serviceIDservice ID
primitiveIDprimitive ID
frameDatadata associated with the frame or NULL if there is no data
frameDataSizetotal size of data to send in multi-frame packet
multiFrameDescpointer to a SCOMMultiFrameDesc structure where the information about multi-frame sending progress will be stored - used to enable iterative sending of multi-frames.
Returns
SCOM_RESULT_OK if the frame was scheduled successfully or SCOM_TX_FRAME_BUFFER_OVERRUN if there is no more free space to buffer the frame or SCOM_ERROR if the multiFrameDesc parameter is NULL

Definition at line 59 of file scom_service.c.

References HAL_PACKED::ctrl, SCOMFrameQueueItem::frame, SCOMDataLinkDesc::frameBuffer, SCOMMultiFrameDesc::multi_id, SCOMDataLinkDesc::multiCounter, HAL_PACKED::null, HAL_PACKED::payload, SCOMMultiFrameDesc::progress, SCOM_ERROR, SCOM_FRAME_CTRL_MULTI_ID_MASK, SCOM_FRAME_TX_READY_FOR_SEND, SCOM_RESULT_OK, SCOM_SOF_CHARACTER, SCOM_TX_FRAME_BUFFER_OVERRUN, SCOMFrame_SetPriority(), SCOMFrameQueue_Insert(), SCOMFrameQueue_Lock(), HAL_PACKED::servicemultiframe, HAL_PACKED::size, HAL_PACKED::sof, SCOMFrameQueueItem::state, SCOMFrameBuffer::txFrameQueue, and HAL_PACKED::type.

SCOMResult SCOM_ServiceTransaction ( SCOMDataLink  scom,
const uint8_t  framePriority,
const uint8_t  serviceID,
const uint8_t  primitiveID,
const void *const  txData,
const uint8_t  txDataSize,
void *  rxData,
const size_t  rxDataSize 
)

Schedules the service transaction - Sends frame using SCOM_SendServiceFrame, inits filter and waits for the response

Parameters
scomSCOM handle
framePrioritypriority of a frame
serviceIDservice ID
primitiveIDprimitive ID
txDatadata associated with the transmitted frame or NULL if there is no data
txDataSizesize of data to be associated with the transmitted frame
rxDatadata pointer to memory address of the data to be received or NULL if there is no data
rxDataSizesize of data to be received
Return values
SCOM_RESULT_OKif the frame was scheduled successfully
SCOM_TX_FRAME_BUFFER_OVERRUNif there is no more free space to buffer the frame
SCOM_FILTER_TIMEOUTif the message was sent but encountered a timeout on reception

Definition at line 143 of file scom_service.c.

References SCOMServiceMatchFilter::filter, SCOM_DeinitializeServiceMatchFilter(), SCOM_ERROR, SCOM_InitializeServiceMatchFilter(), SCOM_InsertFilter(), SCOM_RemoveFilter(), SCOM_RESULT_OK, SCOM_SendServiceFrame(), SCOM_SetupServiceMatchFilter(), and SCOM_WaitForServiceFilter().