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

Main API file. More...

#include "hal.h"
#include "scom.h"
#include "scom_crc.h"
#include <string.h>
#include <stdbool.h>

Go to the source code of this file.

Macros

#define HAL_LOG_CHANNEL   SCOM
 
#define SCOM_MAX_FRAME_REPEAT   2
 Maximum number of retransmissions, before communication error is raised. More...
 
#define SCOM_ACCESS_GUARD_TIMEOUT   5000
 

Functions

SCOMDataLinkDescSCOM_Create (void)
 
void SCOM_Destroy (SCOMDataLinkDesc *const scom)
 
SCOMFrameBufferSCOM_CreateFrameBuffer (size_t rxBuffSize, size_t txBuffSize)
 
void SCOM_DestroyFrameBuffer (SCOMFrameBuffer *const frameBuffer)
 
SCOMResult SCOM_Init (SCOMDataLink scom, IODevice iodevice, SCOMFrameBuffer *frameBuffer, SCOMClockSource clockSource, uint32_t ackTimeout, uint32_t deviceClass, uint8_t *deviceUID, uint8_t numberOfServices, uint8_t *serviceIDs)
 
SCOMResult SCOM_Deinit (SCOMDataLinkDesc *const scom)
 
SCOMResult SCOM_InitAsMonitor (SCOMDataLink scom, IODevice iodevice, SCOMFrameBuffer *frameBuffer, SCOMClockSource clockSource, uint32_t ackTimeout)
 
SCOMResult SCOM_RunProcessingThread (SCOMDataLinkDesc *const scom)
 
void SCOM_StopProcessingThread (SCOMDataLink scom)
 
SCOMResult SCOM_EnableConnectivityCheck (SCOMDataLinkDesc *const scom, const uint32_t checkPeriod)
 
SCOMResult SCOM_DisableConnectivityCheck (SCOMDataLinkDesc *const scom)
 
SCOMConnectionState SCOM_GetConnectionState (const SCOMDataLinkDesc *const scom)
 
IODevice SCOM_GetIODevice (const SCOMDataLinkDesc *const scom)
 
SCOMResult SCOM_SendFrame (SCOMDataLinkDesc *const scom, uint8_t framePriority, uint8_t frameType, const void *frameData, uint8_t frameDataSize)
 
SCOMResult SCOM_SendFrameWithoutAck (SCOMDataLink scom, uint8_t framePriority, uint8_t frameType, const void *frameData, uint8_t frameDataSize)
 
SCOMResult SCOM_SendMultiFrame (SCOMDataLink scom, uint8_t framePriority, uint8_t frameType, const void *frameData, uint32_t frameDataSize, SCOMMultiFrameDesc *multiFrameDesc)
 
SCOMResult SCOM_SendAllocatedMultiFrame (SCOMDataLink scom, SCOMFrame *frame, SCOMMultiFrameDesc *multiFrameDesc)
 
SCOMResult SCOM_AllocFrame (SCOMDataLink scom, SCOMFrame **framePtr)
 
SCOMResult SCOM_SendAllocatedFrame (SCOMDataLink scom, SCOMFrame *frame)
 
SCOMResult SCOM_SendAllocatedFrameWithoutACK (SCOMDataLink scom, SCOMFrame *frame)
 
SCOMResult SCOM_SetFrameReceptionHandlerFunc (SCOMDataLinkDesc *const scom, SCOMFrameReceptionHandler frameReceptionFunc)
 
SCOMResult SCOM_SetAckReceptionHandlerFunc (SCOMDataLinkDesc *const scom, SCOMAckReceptionHandler ackReceptionFunc)
 
SCOMResult SCOM_SetServiceHandler (SCOMDataLink scom, uint8_t serviceID, SCOMServiceHandler serviceHandlerFunc)
 
SCOMResult SCOM_Proc (SCOMDataLink scom)
 
bool SCOM_IsBusy (SCOMDataLink scom)
 
SCOMFrameSCOM_GetReceivedFrame (SCOMDataLink scom)
 
void SCOM_UnlockFrame (SCOMDataLink scom, SCOMFrame *frame)
 
SCOMStatistics SCOM_GetStatistics (const SCOMDataLinkDesc *const scom)
 
void SCOM_ResetStatistics (SCOMDataLinkDesc *const scom)
 

Detailed Description

Main API file.

SCOM Serial communication protocol.

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

Definition in file scom.c.

Macro Definition Documentation

#define HAL_LOG_CHANNEL   SCOM

Definition at line 10 of file scom.c.

#define SCOM_ACCESS_GUARD_TIMEOUT   5000

Defines waiting time for SCOM access mutex in SCOM_Proc function.

Definition at line 25 of file scom.c.

Referenced by SCOM_GetConnectionState(), SCOM_GetStatistics(), SCOM_Proc(), SCOM_ResetStatistics(), SCOM_SetAckReceptionHandlerFunc(), and SCOM_SetFrameReceptionHandlerFunc().

#define SCOM_MAX_FRAME_REPEAT   2

Maximum number of retransmissions, before communication error is raised.

Definition at line 20 of file scom.c.

Function Documentation

SCOMResult SCOM_AllocFrame ( SCOMDataLink  scom,
SCOMFrame **  framePtr 
)

Allocates new frame in the internal SCOM frame buffer, to allow direct access to SCOMFrame structure and avoid unnecessary copying of data. The allocated frame can later be sent using SCOM_SendAllocatedFrame or deleted using SCOM_UnlockFrame.

Parameters
scomSCOM handle
framePtrpointer to variable, where a pointer to an allocated SCOMFrame structure will be stored
Return values
SCOM_RESULT_OKon success - the framePtr holds a valid pointer to SCOMFrame
SCOM_TX_FULLif there is no more free space to allocate frame in the frame buffer
SCOM_ERRORif other error occurred

Definition at line 706 of file scom.c.

References SCOMFrameQueueItem::frame, SCOMDataLinkDesc::frameBuffer, SCOM_ERROR, SCOM_RESULT_OK, SCOM_TX_FULL, SCOMFrameQueue_Lock(), and SCOMFrameBuffer::txFrameQueue.

SCOMDataLinkDesc* SCOM_Create ( void  )

Creates an instance of SCOM descriptor.

Returns
pointer to new SCOM descriptor

Definition at line 146 of file scom.c.

Referenced by SCOM_ScanAndRun().

SCOMFrameBuffer* SCOM_CreateFrameBuffer ( size_t  rxBuffSize,
size_t  txBuffSize 
)

Allocates memory (using heap), creates and initializes a frame buffer for SCOM, of a given size. This frame buffer can than be used in a call to SCOM_Init. Alternatively, if heap memory allocation is discouraged, macro SCOM_DECLARE_FRAME_BUFFER can be used to declare the frame buffer statically.

Parameters
rxBuffSizenumber of incoming frames that can fit into the frame buffer
txBuffSizenumber of outgoing frames that can fit into the frame buffer
Returns
pointer to a frame buffer of NULL if heap allocation failed

Definition of a SCOM frame queue.

Frame pool items

First item in the queue

Pool size (number of managed items)

Pool access mutex

Definition at line 174 of file scom.c.

References SCOMFrameQueue::pool, SCOMFrameBuffer::rxFrameQueue, and SCOMFrameBuffer::txFrameQueue.

Referenced by SCOM_ScanAndRun().

SCOMResult SCOM_Deinit ( SCOMDataLinkDesc *const  scom)
void SCOM_Destroy ( SCOMDataLinkDesc *const  scom)

Destroys an instance of SCOM descriptor.

Parameters
scomSCOM descriptor

Definition at line 161 of file scom.c.

Referenced by SCOM_ScanAndRun().

void SCOM_DestroyFrameBuffer ( SCOMFrameBuffer frameBuffer)

Destroys the frame buffer, previously created with a call to SCOM_CreateFrameBuffer.

Parameters
frameBufferframe buffer to destroy

Definition at line 218 of file scom.c.

SCOMResult SCOM_DisableConnectivityCheck ( SCOMDataLinkDesc *const  scom)
SCOMResult SCOM_EnableConnectivityCheck ( SCOMDataLinkDesc *const  scom,
const uint32_t  checkPeriod 
)
SCOMConnectionState SCOM_GetConnectionState ( const SCOMDataLinkDesc *const  scom)

Checks SCOM connection state.

Parameters
scomSCOM descriptor
Return values
SCOM_CONNECTION_UNINITIALIZEDSCOM connection is not initialized
SCOM_CONNECTION_OPERATIONALconnection is operational
SCOM_CONNECTION_UNSYNCHRONIZEDconnection lost synchronization
SCOM_CONNECTION_BROKENconnection was broken

Definition at line 461 of file scom.c.

References SCOMDataLinkDesc::accessGuard, SCOMDataLinkDesc::connectionState, SCOM_ACCESS_GUARD_TIMEOUT, SCOM_CONNECTION_UNINITIALIZED, and SCOM_RESULT_ERROR.

IODevice SCOM_GetIODevice ( const SCOMDataLinkDesc *const  scom)

Gets the IODevice associated with SCOM.

Parameters
scomSCOM descriptor
Returns
IODevice object

Definition at line 482 of file scom.c.

References SCOMDataLinkDesc::iodevice.

SCOMFrame* SCOM_GetReceivedFrame ( SCOMDataLink  scom)

Gets the oldest received frame that is waiting in the reception queue. The caller is responsible for deleting the frame once it is not needed anymore, through a call to SCOM_UnlockFrame.

Parameters
scomSCOM handle
Returns
pointer to pending frame or NULL if there is no pending frame

Definition at line 1065 of file scom.c.

References SCOMFrameQueueItem::frame, SCOMDataLinkDesc::frameBuffer, SCOMFrameBuffer::rxFrameQueue, and SCOMFrameQueue_GetFirstInQueue().

Referenced by SCOM_FilterProc().

SCOMStatistics SCOM_GetStatistics ( const SCOMDataLinkDesc *const  scom)

Gets current SCOM statistics record.

Parameters
scomSCOM handle
Returns
SCOMStatistics structure

Definition at line 1109 of file scom.c.

References SCOMDataLinkDesc::accessGuard, SCOM_ACCESS_GUARD_TIMEOUT, and SCOMDataLinkDesc::stats.

SCOMResult SCOM_Init ( SCOMDataLink  scom,
IODevice  iodevice,
SCOMFrameBuffer frameBuffer,
SCOMClockSource  clockSource,
uint32_t  ackTimeout,
uint32_t  deviceClass,
uint8_t *  deviceUID,
uint8_t  numberOfServices,
uint8_t *  serviceIDs 
)

Initializes the SCOM protocol on top of the provided IODevice object.

Parameters
scomSCOM descriptor
iodeviceIODevice object used as a hardware interface for SCOM
frameBufferpointer to a frame buffer structure (see SCOM_DECLARE_FRAME_BUFFER)
clockSourcefunction returning current time
ackTimeouttime used for detecting timeout in ACK reception
deviceClassclass of the SCOM device
deviceUIDunique identifier of the SCOM device
numberOfServicesnumber of standard services that will be supported by the protocol - must be less or equal to SCOM_MAX_SERVICES
serviceIDsarray of service identifiers (size equals to numberOfServices)
Returns
SCOM_RESULT_OK on success or SCOM_ERROR if one or more of the provided initialization parameters were invalid

Definition at line 230 of file scom.c.

References SCOMDataLinkDesc::accessGuard, SCOMDataLinkDesc::clockSource, SCOMDataLinkDesc::connectionState, SCOMDataLinkDesc::connectivityCheckIncommingCounter, SCOMDataLinkDesc::connectivityCheckOutgoingCounter, SCOMDataLinkDesc::connectivityCheckPeriod, HAL_PACKED::deviceClass, HAL_PACKED::deviceUID, SCOMACKState::frame, SCOMDataLinkDesc::frameBeingTransmitted, SCOMDataLinkDesc::frameBuffer, SCOMStatistics::framesReceived, SCOMStatistics::framesSent, SCOMDataLinkDesc::id, SCOMDataLinkDesc::iodevice, SCOMDataLinkDesc::lastConnectivityCheckTime, SCOMDataLinkDesc::lastFrameNumber, SCOMDataLinkDesc::multiCounter, SCOMStatistics::retransmissionsReceived, SCOMStatistics::retransmissionsSent, HAL_PACKED::revision, SCOMDataLinkDesc::rxAck, SCOMFrameBuffer::rxFrameQueue, SCOMDataLinkDesc::rxState, SCOM_ACK_SOF_CHARACTER, SCOM_CONNECTION_OPERATIONAL, SCOM_ERROR, SCOM_MAX_FRAME_FILTERS, SCOM_MAX_SERVICES, SCOM_RESULT_OK, SCOM_REVISION, SCOM_RX_WAIT_FOR_SOF, SCOM_VER_HI, SCOM_VER_LO, SCOMFrameQueue_Init(), SCOMDataLinkDesc::serviceCount, HAL_PACKED::soack, SCOMDataLinkDesc::stats, HAL_PACKED::sync, SCOMDataLinkDesc::timeout, SCOMDataLinkDesc::txCounter, SCOMFrameBuffer::txFrameQueue, HAL_PACKED::verHi, HAL_PACKED::verLo, and HAL_PACKED::version.

Referenced by SCOM_InitAsMonitor(), and SCOM_ScanAndRun().

SCOMResult SCOM_InitAsMonitor ( SCOMDataLink  scom,
IODevice  iodevice,
SCOMFrameBuffer frameBuffer,
SCOMClockSource  clockSource,
uint32_t  ackTimeout 
)

Initializes the SCOM protocol on top of the provided IODevice object but as a protocol monitor only.

Parameters
scomSCOM descriptor
iodeviceIODevice object used as a hardware interface for SCOM
frameBufferpointer to a frame buffer structure (see SCOM_DECLARE_FRAME_BUFFER)
clockSourcefunction returning current time
ackTimeouttime used for detecting timeout in ACK reception
Returns
SCOM_RESULT_OK on success or SCOM_ERROR if one or more of the provided initialization parameters were invalid

Definition at line 363 of file scom.c.

References SCOMDataLinkDesc::monitorMode, SCOM_Init(), and SCOM_RESULT_OK.

bool SCOM_IsBusy ( SCOMDataLink  scom)

Checks if SCOM is in the middle of some sending or receiving process.

Parameters
scomSCOM handle
Returns
true if SCOM is busy, false otherwise

Definition at line 1044 of file scom.c.

References SCOMDataLinkDesc::frameBeingTransmitted, SCOMDataLinkDesc::frameBuffer, SCOM_FRAME_EMPTY, SCOM_FRAME_TX_SENT, SCOMFrameQueue_GetFirstInQueue(), SCOMFrameQueueItem::state, and SCOMFrameBuffer::txFrameQueue.

SCOMResult SCOM_Proc ( SCOMDataLink  scom)

Implements the SCOM data link layer procedures. Must be called periodically (for ex. in an OS task).

Parameters
scomSCOM handle
Return values
SCOM_RESULT_OKon success
SCOM_COMMUNICATION_ERRORif a communication error was detected
SCOM_SYNCHRONIZATION_ERRORif link was desynchronized
SCOM_ERRORif other error occurred

Definition at line 859 of file scom.c.

References SCOMDataLinkDesc::accessGuard, SCOMDataLinkDesc::clockSource, SCOMDataLinkDesc::connectionState, HAL_PACKED::crc, SCOMFrameQueueItem::frame, SCOMACKState::frame, SCOMDataLinkDesc::frameBeingReceived, SCOMDataLinkDesc::frameBeingTransmitted, SCOMDataLinkDesc::frameBuffer, SCOMStatistics::framesReceived, SCOMStatistics::framesSent, SCOMDataLinkDesc::iodevice, SCOMDataLinkDesc::lastConnectivityCheckTime, SCOMDataLinkDesc::receptionTime, SCOMStatistics::retransmissionsReceived, SCOMStatistics::retransmissionsSent, SCOMDataLinkDesc::rxAck, SCOMDataLinkDesc::rxState, SCOM_ACCESS_GUARD_TIMEOUT, SCOM_ACK_SOF_CHARACTER, SCOM_COMMUNICATION_ERROR, SCOM_CONNECTION_BROKEN, SCOM_CONNECTION_OPERATIONAL, SCOM_CONNECTION_UNSYNCHRONIZED, SCOM_ERROR, SCOM_FRAME_TX_READY_FOR_SEND, SCOM_RESULT_OK, SCOM_RX_ACK, SCOM_RX_FRAME, SCOM_RX_WAIT_FOR_SOF, SCOM_SOF_CHARACTER, SCOM_SYNCHRONIZATION_ERROR, SCOMAckFrame_CalculateCRC(), SCOMAckFrame_Initialize(), SCOMAckFrame_IsValidAck(), SCOMFrame_IsAcknowledged(), SCOMFrame_SetFrameNumber(), SCOMFrameQueue_GetFirstInQueue(), SCOMFrameQueue_Unlock(), SCOMDataLinkDesc::sendTime, SCOMFrameQueueItem::state, SCOMACKState::state, SCOMDataLinkDesc::stats, SCOMDataLinkDesc::timeout, SCOMDataLinkDesc::txAck, SCOMFrameBuffer::txFrameQueue, and HAL_PACKED::type.

void SCOM_ResetStatistics ( SCOMDataLinkDesc *const  scom)
SCOMResult SCOM_RunProcessingThread ( SCOMDataLinkDesc *const  scom)

Definition at line 403 of file scom.c.

References SCOMDataLinkDesc::procTask, SCOM_RESULT_ERROR, and SCOM_RESULT_OK.

Referenced by SCOM_ScanAndRun().

SCOMResult SCOM_SendAllocatedFrame ( SCOMDataLink  scom,
SCOMFrame frame 
)

Schedules transmission of a frame, that was previously allocated with SCOM_AllocFrame. The frame should have already these properties set: type, priority, dataSize. After being sent, the frame is automatically deleted (unlocked) - there is no need to explicitly call SCOM_UnlockFrame.

Parameters
scomSCOM handle
frameframe previously allocated with SCOM_AllocFrame
Return values
SCOM_RESULT_OKif the frame transmission was scheduled successfully
SCOM_FRAME_NOT_IN_BUFFERif the frame is not part of the SCOM frame buffer
SCOM_ERRORif other error occurred

Definition at line 735 of file scom.c.

References SCOMDataLinkDesc::frameBuffer, HAL_PACKED::null, SCOM_ERROR, SCOM_FRAME_NOT_IN_BUFFER, SCOM_FRAME_TX_READY_FOR_SEND, SCOM_RESULT_OK, SCOM_SOF_CHARACTER, SCOMFrameQueue_GetItemByFrame(), SCOMFrameQueue_Insert(), HAL_PACKED::sof, SCOMFrameQueueItem::state, and SCOMFrameBuffer::txFrameQueue.

SCOMResult SCOM_SendAllocatedFrameWithoutACK ( SCOMDataLink  scom,
SCOMFrame frame 
)

Schedules transmission of a frame, that was previously allocated with SCOM_AllocFrame. The frame should have already these properties set: type, priority, dataSize. After being sent, the frame is automatically deleted (unlocked) - there is no need to explicitly call SCOM_UnlockFrame.

Parameters
scomSCOM handle
frameframe previously allocated with SCOM_AllocFrame
Return values
SCOM_RESULT_OKif the frame transmission was scheduled successfully
SCOM_FRAME_NOT_IN_BUFFERif the frame is not part of the SCOM frame buffer
SCOM_ERRORif other error occurred

Definition at line 766 of file scom.c.

References SCOMDataLinkDesc::frameBuffer, HAL_PACKED::null, SCOM_ERROR, SCOM_FRAME_NOT_IN_BUFFER, SCOM_FRAME_TX_READY_FOR_SEND, SCOM_RESULT_OK, SCOM_SOF_CHARACTER, SCOMFrame_SetAcknowledgement(), SCOMFrameQueue_GetItemByFrame(), SCOMFrameQueue_Insert(), HAL_PACKED::sof, SCOMFrameQueueItem::state, and SCOMFrameBuffer::txFrameQueue.

SCOMResult SCOM_SendAllocatedMultiFrame ( SCOMDataLink  scom,
SCOMFrame frame,
SCOMMultiFrameDesc multiFrameDesc 
)

Schedules transmission of a mulitframe, that was previously allocated with SCOM_AllocFrame. The frame should have already these properties set: type, priority, dataSize. After being sent, the frame is automatically deleted (unlocked) - there is no need to explicitly call SCOM_UnlockFrame.

Parameters
scomSCOM handle
frameframe previously allocated with SCOM_AllocFrame
multiFrameDescpointer to a multiframe descriptor, that holds information about a multiframe sending process
Return values
SCOM_RESULT_OKif the frame transmission was scheduled successfully
SCOM_FRAME_NOT_IN_BUFFERif the frame is not part of the SCOM frame buffer
SCOM_ERRORif other error occurred

Definition at line 650 of file scom.c.

References HAL_PACKED::ctrl, SCOMDataLinkDesc::frameBuffer, SCOMMultiFrameDesc::multi_id, SCOMDataLinkDesc::multiCounter, HAL_PACKED::multiframe, HAL_PACKED::null, HAL_PACKED::payload, SCOMMultiFrameDesc::progress, SCOM_ERROR, SCOM_FRAME_CTRL_MULTI_ID_MASK, SCOM_FRAME_NOT_IN_BUFFER, SCOM_FRAME_TX_READY_FOR_SEND, SCOM_RESULT_OK, SCOM_SOF_CHARACTER, SCOMFrameQueue_GetItemByFrame(), SCOMFrameQueue_Insert(), HAL_PACKED::size, HAL_PACKED::sof, SCOMFrameQueueItem::state, and SCOMFrameBuffer::txFrameQueue.

SCOMResult SCOM_SendFrame ( SCOMDataLinkDesc *const  scom,
uint8_t  framePriority,
uint8_t  frameType,
const void *  frameData,
uint8_t  frameDataSize 
)
SCOMResult SCOM_SendFrameWithoutAck ( SCOMDataLink  scom,
uint8_t  framePriority,
uint8_t  frameType,
const void *  frameData,
uint8_t  frameDataSize 
)

WARNING: THIS FUNCTION SENDS THE FRAME WITHOUT ACKNOWLEDGEMENT. NO RETRANSMISSION WILL BE HANDLED.

Schedules the 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
frameTypetype of frame
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 530 of file scom.c.

References HAL_PACKED::ctrl, SCOMFrameQueueItem::frame, SCOMDataLinkDesc::frameBuffer, HAL_PACKED::null, HAL_PACKED::payload, SCOM_ERROR, SCOM_FRAME_TX_READY_FOR_SEND, SCOM_RESULT_OK, SCOM_SOF_CHARACTER, SCOM_TX_FRAME_BUFFER_OVERRUN, SCOMFrame_SetAcknowledgement(), SCOMFrame_SetPriority(), SCOMFrameQueue_Insert(), SCOMFrameQueue_Lock(), HAL_PACKED::singleframe, HAL_PACKED::size, HAL_PACKED::sof, SCOMFrameQueueItem::state, SCOMFrameBuffer::txFrameQueue, and HAL_PACKED::type.

Referenced by SCOM_WaitForDevice().

SCOMResult SCOM_SendMultiFrame ( SCOMDataLink  scom,
uint8_t  framePriority,
uint8_t  frameType,
const void *  frameData,
uint32_t  frameDataSize,
SCOMMultiFrameDesc multiFrameDesc 
)

Schedules sending of another part of multi-frame 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
frameTypetype of frame
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 574 of file scom.c.

References HAL_PACKED::ctrl, SCOMFrameQueueItem::frame, SCOMDataLinkDesc::frameBuffer, SCOMMultiFrameDesc::multi_id, SCOMDataLinkDesc::multiCounter, HAL_PACKED::multiframe, 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::size, HAL_PACKED::sof, SCOMFrameQueueItem::state, SCOMFrameBuffer::txFrameQueue, and HAL_PACKED::type.

SCOMResult SCOM_SetAckReceptionHandlerFunc ( SCOMDataLinkDesc *const  scom,
SCOMAckReceptionHandler  ackReceptionFunc 
)
SCOMResult SCOM_SetFrameReceptionHandlerFunc ( SCOMDataLinkDesc *const  scom,
SCOMFrameReceptionHandler  frameReceptionFunc 
)
SCOMResult SCOM_SetServiceHandler ( SCOMDataLink  scom,
uint8_t  serviceID,
SCOMServiceHandler  serviceHandlerFunc 
)

Sets the service frame reception handler. This handler is a function that will be called by the SCOM each time a service frame with the matching serviceID is received. Note however, that all the serviceIDs that should be handled need to be defined during the call to SCOM_Init .

Parameters
scomSCOM handle
serviceIDserviceID
serviceHandlerFuncpointer to the handler function
Returns
SCOM_RESULT_OK on success SCOM_RESULT_ERROR on error

Definition at line 841 of file scom.c.

References SCOM_MAX_SERVICES, SCOM_RESULT_ERROR, and SCOM_RESULT_OK.

void SCOM_StopProcessingThread ( SCOMDataLink  scom)

Starts the thread, previously started with SCOM_RunProcessingThread.

Parameters
scomSCOM descriptor

Definition at line 420 of file scom.c.

References SCOMDataLinkDesc::procTask.

Referenced by SCOM_ScanAndRun().

void SCOM_UnlockFrame ( SCOMDataLink  scom,
SCOMFrame frame 
)

Deletes the frame that was either received through a call to SCOM_GetReceivedFrame or was allocated using SCOM_AllocFrame, but was not sent using SCOM_SendAllocatedFrame.

Parameters
scomSCOM handle
frameframe to delete

Definition at line 1086 of file scom.c.

References SCOMDataLinkDesc::frameBuffer, SCOMFrameBuffer::rxFrameQueue, SCOMFrameQueue_GetItemByFrame(), SCOMFrameQueue_Unlock(), and SCOMFrameBuffer::txFrameQueue.

Referenced by SCOM_FilterProc().