SCOM Serial Communication Protocol  0.5.2
Functions
scom_utils.h File Reference

Various utils. More...

#include "scom.h"

Go to the source code of this file.

Functions

SCOMResult SCOM_GetIdentity (SCOMDataLink scom, SCOMIdentity *identity)
 
unsigned int SCOM_ScanAndRun (void(*initProc)(IODevice iodevice, const char *deviceName), bool(*userProc)(SCOMDataLink scom, SCOMIdentity *identity, const char *deviceName), uint32_t responseTimeout)
 
SCOMResult SCOM_WaitForDevice (SCOMDataLink scom, uint32_t expectedDeviceClass, uint32_t expectedDeviceClassMask, uint32_t probeInterval, uint32_t timeout, SCOMIdentity *identity)
 

Detailed Description

Various utils.

Some handy utilities for SCOM Serial communication protocol.

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

Definition in file scom_utils.h.

Function Documentation

SCOMResult SCOM_GetIdentity ( SCOMDataLink  scom,
SCOMIdentity identity 
)

Gets the identity of the remote SCOM device.

This function requires a working SCOM object with enabled frame filtering. It sends a standard SCOM IDENTIFY request to a remote device and reads out the identity of the remote device. The identity information is written to a place pointed by identity. The identity information includes SCOM version, device class, UID and a list of supported services. For details please refer to SCOMIdentity.

Parameters
scomSCOM descriptor (requires initialized SCOM object with enabled filtering)
identityplace to store the identity information
Return values
SCOM_RESULT_OKwhen the identity of the remote device was successfully retrieved
unsigned int SCOM_ScanAndRun ( void(*)(IODevice iodevice, const char *deviceName)  initProc,
bool(*)(SCOMDataLink scom, SCOMIdentity *identity, const char *deviceName)  userProc,
uint32_t  responseTimeout 
)

Scans all available serial ports using IOSerial interface. Tries to open each serial port. If successful runs the user initialization procedure (initProc) and then tries to connect using SCOM protocol. If successful, gets the identity information from the remote device and runs user procedure (userProc). The user procedure can then interact with the device. If the user procedure returns true, the device will be counted as a "valid" device. The counter is returned as a result of this function. If no user procedure is provided, all SCOM devices are counted as "valid".

This utility is handy for running tasks across all SCOM devices connected to a computer.

Parameters
[in]initProcinitialization procedure run for all successfully opened serial ports, prior to SCOM communication
[in]userProcuser-defined procedure run for all successfully identified SCOM devices
[in]responseTimeoutmaximum time waiting for response from SCOM device during scanning
Returns
number of SCOM devices found, that are valid in terms of the user-procedure

Definition at line 134 of file scom_utils.c.

References SCOM_Create(), SCOM_CreateFrameBuffer(), SCOM_Deinit(), SCOM_DeinitFiltering(), SCOM_Destroy(), SCOM_Init(), SCOM_InitFiltering(), SCOM_RESULT_OK, SCOM_RunFilteringThread(), SCOM_RunProcessingThread(), SCOM_StopFilteringThread(), SCOM_StopProcessingThread(), and SCOM_WaitForDevice().

SCOMResult SCOM_WaitForDevice ( SCOMDataLink  scom,
uint32_t  expectedDeviceClass,
uint32_t  expectedDeviceClassMask,
uint32_t  probeInterval,
uint32_t  timeout,
SCOMIdentity identity 
)

Waits for a given SCOM device, trying to identify it and match against a given DeviceClass.

This function periodically sends identification requests to the device every given probe interval. These requests do not require ACK, so that in case of no response no error is reported. If identification response is received, the remote DeviceClass from the response is compared against the expected DeviceClass. This comparison is additionally masked, so that only required bits are compared. The function exits when the compare yields match or when given timeout occurs. Both the interval and timeout are expressed in SCOM clock time units.

Parameters
[in]scomSCOM descriptor (requires initialized SCOM object with enabled filtering)
[in]expectedDeviceClassexpected value of the DeviceClass identification parameter
[in]expectedDeviceClassMaskmask used when comparing the received DeviceClass with the expected
[in]probeIntervaltime interval between consecutive identify requests
[in]timeoutmaximum time waiting for a matching identity
[out]identityplace to store the retrieved remote device identity - only available if matched DeviceClass has been found
Return values
SCOM_RESULT_OKwhen the identity of the remote device was successfully retrieved
SCOM_NO_DEVICEwhen no matching remote device was detected

Definition at line 64 of file scom_utils.c.

References SCOMDataLinkDesc::clockSource, HAL_PACKED::deviceClass, SCOMFrameTypeMatchFilter::filter, SCOM_DeinitializeFrameTypeMatchFilter(), SCOM_ERROR, SCOM_FILTER_ERROR, SCOM_FILTER_LIST_FULL, SCOM_FRAMETYPE_IDENTIFY, SCOM_InitializeFrameTypeMatchFilter(), SCOM_InsertFilter(), SCOM_NO_DEVICE, SCOM_RemoveFilter(), SCOM_RESULT_OK, SCOM_SendFrameWithoutAck(), SCOM_SetupFrameTypeMatchFilter(), and SCOM_WaitForFrameTypeFilter().

Referenced by SCOM_ScanAndRun().