SCOM Serial Communication Protocol  0.5.2
Data Structures | Macros | Typedefs | Functions
scom_filtering.h File Reference

Packet filtering API. More...

#include "scom.h"
#include "hal_config.h"
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  SCOMFilterDesc
 Actual definition of the SCOM frame filter descriptor structure. More...
 

Macros

#define SCOM_DECLARE_FILTER_FRAME_POOL(name, size)
 

Typedefs

typedef struct SCOMFilterFrame SCOMFilterFrame
 Type declaration of the SCOM frame filter. More...
 
typedef struct SCOMFilterDesc SCOMFilterDesc
 Type declaration of the SCOM frame filter descriptor. More...
 
typedef struct SCOMFilterDescSCOMFilter
 Utility type being a pointer to a SCOM frame filter descriptor. More...
 
typedef bool(* SCOMFilterMatchFunc )(SCOMDataLink scom, SCOMFilter filter, SCOMFrame *frame)
 Type defining a function that performs filter matching (returns 1 when frame matches filter, 0 otherwise) More...
 

Functions

bool SCOM_FilteringFrameReceptionHandler (SCOMDataLink scom, SCOMFrame *frame)
 
SCOMResult SCOM_InsertFilter (SCOMDataLink scom, SCOMFilter filter)
 
SCOMResult SCOM_RemoveFilter (SCOMDataLink scom, SCOMFilter filter)
 
SCOMResult SCOM_InitFiltering (SCOMDataLink scom)
 
SCOMResult SCOM_DeinitFiltering (SCOMDataLink scom)
 
void SCOM_FilterProc (SCOMDataLink scom)
 
SCOMResult SCOM_RunFilteringThread (SCOMDataLink scom)
 
void SCOM_StopFilteringThread (SCOMDataLink scom)
 

Detailed Description

Packet filtering API.

Frame filtering for the SCOM Serial communication protocol.

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

Definition in file scom_filtering.h.

Macro Definition Documentation

#define SCOM_DECLARE_FILTER_FRAME_POOL (   name,
  size 
)

This macro create filter buffer structure.

Parameters
name- buffer name
size- number of SCOMbuffer size

Definition at line 28 of file scom_filtering.h.

Typedef Documentation

typedef struct SCOMFilterDesc* SCOMFilter

Utility type being a pointer to a SCOM frame filter descriptor.

Definition at line 41 of file scom_filtering.h.

Type declaration of the SCOM frame filter descriptor.

Definition at line 38 of file scom_filtering.h.

Type declaration of the SCOM frame filter.

Definition at line 35 of file scom_filtering.h.

typedef bool(* SCOMFilterMatchFunc)(SCOMDataLink scom, SCOMFilter filter, SCOMFrame *frame)

Type defining a function that performs filter matching (returns 1 when frame matches filter, 0 otherwise)

Definition at line 44 of file scom_filtering.h.

Function Documentation

SCOMResult SCOM_DeinitFiltering ( SCOMDataLink  scom)

Deinitialize filter structure.

Parameters
scomSCOM handle
Return values
SCOM_RESULT_OK
SCOM_ERRORwhen SCOM handle not exist

Definition at line 206 of file scom_filtering.c.

References SCOMDataLinkDesc::accessGuard, SCOM_ERROR, SCOM_FILTERING_ACCESS_GUARD_TIMEOUT, and SCOM_RESULT_OK.

Referenced by SCOM_ScanAndRun().

bool SCOM_FilteringFrameReceptionHandler ( SCOMDataLink  scom,
SCOMFrame frame 
)

Function used as a native SCOM frame reception handler when frame filtering capabilities are required. In order to enable filtering capabilities, this function shall be passed to the SCOM_SetFrameReceptionHandlerFunc after SCOM initialization. This function is never called directly - it is used internally by the SCOM protocol.

Parameters
scomSCOM handle
framepointer to the received frame

Definition at line 29 of file scom_filtering.c.

Referenced by SCOM_InitFiltering().

void SCOM_FilterProc ( SCOMDataLink  scom)

This function must be called periodically.

Parameters
scomSCOM handle

Definition at line 45 of file scom_filtering.c.

References SCOMDataLinkDesc::accessGuard, SCOMFilterDesc::filter_match_function, SCOM_FILTERING_ACCESS_GUARD_TIMEOUT, SCOM_GetReceivedFrame(), SCOM_UnlockFrame(), and HAL_PACKED::type.

SCOMResult SCOM_InitFiltering ( SCOMDataLink  scom)

Initialize filter structure.

Parameters
scomSCOM handle
Return values
SCOM_RESULT_OKwhen structure was initialized successfully
SCOM_RESULT_OKwhen an error occurred, for example framePool pointer is equal NULL

Definition at line 167 of file scom_filtering.c.

References SCOMDataLinkDesc::accessGuard, SCOMDataLinkDesc::frameBuffer, SCOMFrameBuffer::rxFrameQueue, SCOM_ERROR, SCOM_FILTERING_ACCESS_GUARD_TIMEOUT, SCOM_FilteringFrameReceptionHandler(), SCOM_MAX_FRAME_FILTERS, SCOM_RESULT_OK, SCOM_SetFrameReceptionHandlerFunc(), and SCOMFrameQueue::size.

Referenced by SCOM_ScanAndRun().

SCOMResult SCOM_InsertFilter ( SCOMDataLink  scom,
SCOMFilter  filter 
)

Inserts the provided filter into a SCOM filter chain.

Parameters
scomSCOM handle
filterSCOM filter
Return values
SCOM_RESULT_OKwhen filter was properly installed
SCOM_FILTER_LIST_FULLwhen the filter list is full and cannot accept more filters (consider increasing the SCOM_MAX_FRAME_FILTERS definition)

Definition at line 101 of file scom_filtering.c.

References SCOMDataLinkDesc::accessGuard, SCOM_FILTER_LIST_FULL, SCOM_FILTERING_ACCESS_GUARD_TIMEOUT, and SCOM_RESULT_OK.

Referenced by SCOM_GetIdentity(), SCOM_ServiceTransaction(), SCOM_Transaction(), and SCOM_WaitForDevice().

SCOMResult SCOM_RemoveFilter ( SCOMDataLink  scom,
SCOMFilter  filter 
)

Removes the filter from the SCOM filter chain.

Parameters
scomSCOM handle
filterSCOM filter
Returns
always SCOM_RESULT_OK

Definition at line 134 of file scom_filtering.c.

References SCOMDataLinkDesc::accessGuard, SCOM_ERROR, SCOM_FILTERING_ACCESS_GUARD_TIMEOUT, and SCOM_RESULT_OK.

Referenced by SCOM_GetIdentity(), SCOM_ServiceTransaction(), SCOM_Transaction(), and SCOM_WaitForDevice().

SCOMResult SCOM_RunFilteringThread ( SCOMDataLink  scom)

Creates and starts the thread that periodically calls the SCOM_FilterProc function, that actually runs the filtering engine.

Parameters
scomSCOM descriptor
Returns
SCOM_RESULT_OK on success or SCOM_ERROR if thread creation failed

Definition at line 261 of file scom_filtering.c.

References SCOM_ERROR, and SCOM_RESULT_OK.

Referenced by SCOM_ScanAndRun().

void SCOM_StopFilteringThread ( SCOMDataLink  scom)

Stops the thread, previously started with SCOM_RunFilteringThread.

Parameters
scomSCOM descriptor

Definition at line 279 of file scom_filtering.c.

Referenced by SCOM_ScanAndRun().