SCOM Serial Communication Protocol
0.5.2
|
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) |
Various utils.
Some handy utilities for SCOM Serial communication protocol.
Definition in file scom_utils.h.
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.
scom | SCOM descriptor (requires initialized SCOM object with enabled filtering) |
identity | place to store the identity information |
SCOM_RESULT_OK | when 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.
[in] | initProc | initialization procedure run for all successfully opened serial ports, prior to SCOM communication |
[in] | userProc | user-defined procedure run for all successfully identified SCOM devices |
[in] | responseTimeout | maximum time waiting for response from SCOM device during scanning |
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.
[in] | scom | SCOM descriptor (requires initialized SCOM object with enabled filtering) |
[in] | expectedDeviceClass | expected value of the DeviceClass identification parameter |
[in] | expectedDeviceClassMask | mask used when comparing the received DeviceClass with the expected |
[in] | probeInterval | time interval between consecutive identify requests |
[in] | timeout | maximum time waiting for a matching identity |
[out] | identity | place to store the retrieved remote device identity - only available if matched DeviceClass has been found |
SCOM_RESULT_OK | when the identity of the remote device was successfully retrieved |
SCOM_NO_DEVICE | when 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().