SCOM Serial Communication Protocol
0.5.2
|
Once the SCOM protocol is running, it is possible to schedule sending of SCOM packets. The SCOM API provides several ways to do that.
Sending single-frames
If the required packet payload is small enough to fit into a single frame (see SCOM_MAX_DATA_LENGTH) then the easiest way to send a packet is to call the SCOM_SendFrame function:
Calling the SCOM_SendFrame does not automatically send the frame. Instead it buffers it in the frame buffer and it is the SCOM_Proc responsibility do decide which of the buffered packets will be send next, based on the priority - thus the result of SCOM_SendFrame does not reflect the status of actual sending process.
Sending single-frames using pre-allocation
Sometimes it is more convenient to access the internal payload buffer of the frame, for easier completion of the payload, instead of building such structure and then passing it to SCOM_SendFrame. To achieve that it is possible to first allocate an SCOM frame and then complete it and send it.
The SCOM_AllocFrame allocates a frame in the frame buffer and returns a pointer to SCOMFrame structure:
This structure can be then used to build the frame and complete it's payload:
Once the frame is ready, it can be sent using SCOM_SendAllocatedFrame :
Sending multi-frames
The multi-frame mechanism provides an easy way for fragmentation of larger payloads across multiple SCOM frames. The API provides a special function for sending multi-frames: SCOM_SendMultiFrame. Apart from standard SCOM frame description, this function also requires a pointer to a SCOMMultiFrameDesc structure that describes the whole large payload transfer. Each call to SCOM_SendMultiFrame sends a single SCOM frame with sequential parts of the payload, and updates the transfer descriptor. Below is an exemplary usage
Sending service frames
In order to support service frames, a convenient function SCOM_SendServiceFrame is provided in the API. Here's the exemplary usage: