SCOM Serial Communication Protocol
0.5.2
|
The SCOM descriptor
The SCOMDataLinkDesc structure holds a complete description of an SCOM protocol instance. Most SCOM API calls require a pointer to this structure as an argument. The SCOM descriptor can be simply declared by the user:
In environments where heap memory is available, it can also be created dynamically using SCOM_Create, and possibly freed after usage using SCOM_Destroy.
Frame buffer
SCOM instance requires a frame buffer. The frame buffer is a structure, that internally maintains a space for SCOM packets that are transmitted and received. The SCOM API provides two types of frame buffers:
In order to declare a static SCOM frame buffer, the SCOM_DECLARE_FRAME_BUFFER macro can be used:
To declare a dynamic SCOM frame buffer, the SCOM_DECLARE_FRAME_BUFFER_USING_HEAP macro can be used:
It is also possible to create the frame buffer using SCOM API call SCOM_CreateFrameBuffer and later destroy it using SCOM_DestroyFrameBuffer.
The frame buffer is used during SCOM connection initialization.
Timing
The SCOM protocol is a real-time tool, meaning that it requires timing operation in order to behave correctly. During initialization, the user provides a timing function, that is internally called by the SCOM functions to get information about current time. This function should return a monotonic, stable clock. A good example would be a function returning the count of milliseconds elapsed since the system started.
Initializing the SCOM connection.
The SCOM_Init function initializes the given SCOM protocol instance, preparing it for operation. Several arguments are required to successfully set up the protocol:
The following example illustrates how to initialize the connection:
Deinitializing the SCOM connection.
When done with the protocol, simply call SCOM_Deinit to deinitialize the connection instance and free up all allocated resources.
Retrieving IODevice associated with the SCOM connection.
The SCOM_GetIODevice function allows to retrieve at any time the IODevice associated with the given SCOM connection object.