15 #define SCOM_REVISION 0
18 #if defined __cplusplus
37 #define SCOM_DECLARE_FRAME_BUFFER(name, txQueueSize, rxQueueSize) \
38 SCOMFrameQueueItem name##_scom_tx_frame_pool[txQueueSize]; \
39 SCOMFrameQueueItem name##_scom_rx_frame_pool[rxQueueSize]; \
40 SCOMFrameBuffer name = {{name##_scom_tx_frame_pool, NULL, txQueueSize, NULL}, \
41 {name##_scom_rx_frame_pool, NULL, rxQueueSize, NULL}}
50 #define SCOM_DECLARE_FRAME_BUFFER_USING_HEAP(name) \
51 SCOMFrameBuffer name = { {NULL, NULL, 0, NULL}, \
52 { NULL, NULL, 0, NULL}}
57 #if SCOM_MAX_FRAME_FILTERS > 0
58 typedef struct SCOMFilterFramePool SCOMFilterFramePool;
72 #if 1 == defined HAL_ENABLE_OS
92 #if SCOM_MAX_SERVICES > 0
97 #define SCOM_DEVICE_INFO_LEN (sizeof(((SCOMIdentity *)0)->version) + sizeof(((SCOMIdentity *)0)->deviceClass) + sizeof(((SCOMIdentity *)0)->deviceUID))
153 #if defined SCOM_RECEPTION_TIMEOUT_AFTER_FRAME_START
154 uint32_t receptionStartTime;
165 #if SCOM_MAX_SERVICES > 0
174 #if SCOM_MAX_FRAME_FILTERS > 0
180 SCOMFilterFramePool *framePool;
182 #if defined HAL_ENABLE_OS && (HAL_ENABLE_OS == 1)
187 #if 1 == HAL_ENABLE_OS
240 #define SCOM_ERR__COMMUNICATION_ERROR 1
241 #define SCOM_ERR__INTERNAL_ERROR 2
242 #define SCOM_ERR__DATA_TOO_LARGE 3
243 #define SCOM_ERR__TX_OVERLOAD 4
244 #define SCOM_ERR__SYNCHRONIZATION_ERROR 5
307 uint32_t deviceClass, uint8_t* deviceUID,
308 uint8_t numberOfServices, uint8_t* serviceIDs
405 SCOMResult SCOM_SendFrame(SCOMDataLink scom, uint8_t framePriority, uint8_t frameType,
const void* frameData, uint8_t frameDataSize);
599 #if defined __cplusplus
Definition of multiframe descriptor structure.
SCOMResult SCOM_InitAsMonitor(SCOMDataLink scom, IODevice iodevice, SCOMFrameBuffer *frameBuffer, SCOMClockSource clockSource, uint32_t ackTimeout)
SCOMFrameQueue rxFrameQueue
descriptor of the frame queue used for receiving
void SCOM_DestroyFrameBuffer(SCOMFrameBuffer *frameBuffer)
SCOMFrameQueue txFrameQueue
descriptor of the frame queue used for sending
SCOMVersion version
SCOM version record.
SCOMResult SCOM_SetServiceHandler(SCOMDataLink scom, uint8_t serviceID, SCOMServiceHandler serviceHandlerFunc)
SCOMResult SCOM_Proc(SCOMDataLink scom)
uint32_t timeout
Clock source provider function.
SCOM Data Link descriptor.
Descriptor of the SCOM statistics.
#define SCOM_MAX_SERVICES
uint32_t progress
multiframe id
SCOMResult SCOM_SendFrame(SCOMDataLink scom, uint8_t framePriority, uint8_t frameType, const void *frameData, uint8_t frameDataSize)
SCOMResult SCOM_Deinit(SCOMDataLink scom)
OSTask procTask
mutex guarding access to this object
SCOMResult SCOM_EnableConnectivityCheck(SCOMDataLink scom, uint32_t checkPeriod)
SCOMACKState txAck
Descriptor holding the received ACK.
uint32_t multiCounter
Counter increased after every frame scheduled to send.
uint32_t connectivityCheckIncommingCounter
Time at which last connectivity check was performed.
uint8_t deviceUID[16]
Device unique identifier.
Definition of a single SCOM frame queue item.
SCOMFrame * SCOM_GetReceivedFrame(SCOMDataLink scom)
bool SCOM_IsBusy(SCOMDataLink scom)
SCOMResult SCOM_SetAckReceptionHandlerFunc(SCOMDataLink scom, SCOMAckReceptionHandler ackReceptionFunc)
uint32_t retransmissionsReceived
Number of retransmissions detected when receiving frames.
SCOMResult SCOM_DisableConnectivityCheck(SCOMDataLink scom)
void SCOM_ResetStatistics(SCOMDataLink scom)
IODevice SCOM_GetIODevice(const SCOMDataLinkDesc *const scom)
void(* SCOMAckReceptionHandler)(SCOMDataLink scom, uint8_t frame_type)
SCOMDataLinkDesc * SCOMDataLink
bool monitorMode
State of the SCOM receiver.
SCOMResult SCOM_SetFrameReceptionHandlerFunc(SCOMDataLink scom, SCOMFrameReceptionHandler frameReceptionFunc)
uint32_t lastConnectivityCheckTime
Time period for checking connection status.
struct HAL_PACKED SCOMIdentity
Definition of a structure that identifies an SCOM device.
SCOMConnectionState
Possible SCOM connection states.
void SCOM_StopProcessingThread(SCOMDataLink scom)
SCOMReceiverState
Possible receiver states.
SCOMClockSource clockSource
IODevice object implementing the hardware interface.
SCOMACKState rxAck
frame buffer - holds the queues used for sending and receiving SCOM frames
uint16_t lastFrameCrc
Number of the last received frame.
SCOMFrameQueueItem * frameBeingTransmitted
Frame buffer item that is being used as a place for a currently receiving frame.
struct SCOMDataLinkDesc SCOMDataLinkDesc
SCOM Data Link descriptor.
bool(* SCOMFrameReceptionHandler)(SCOMDataLink scom, SCOMFrame *frame)
uint32_t retransmissionsSent
Number of retransmissions needed when sending frames.
uint32_t deviceClass
Device class.
SCOMResult SCOM_Init(SCOMDataLink scom, IODevice iodevice, SCOMFrameBuffer *frameBuffer, SCOMClockSource clockSource, uint32_t ackTimeout, uint32_t deviceClass, uint8_t *deviceUID, uint8_t numberOfServices, uint8_t *serviceIDs)
uint8_t retransmissionCounter
Frame buffer item that is currently being sent.
bool(* receptionHandler)(struct SCOMDataLinkDesc *scom, SCOMFrame *frame)
Outgoing PING counter.
SCOMFrameQueueItem * frameBeingReceived
Descriptor holding the ACK to transmit.
uint32_t connectivityCheckOutgoingCounter
Incomming PING counter.
uint32_t txCounter
Received frame time.
struct HAL_PACKED SCOMVersion
SCOM version record.
SCOMFrameState state
ACK frame.
uint32_t connectivityCheckPeriod
Counter increased after every first frame of a multi-frame is scheduled to send.
SCOMIdentity id
Packet timeout.
uint16_t revision
protocol revision
void SCOM_UnlockFrame(SCOMDataLink scom, SCOMFrame *frame)
OSTime(* SCOMClockSource)(void)
void SCOM_Destroy(SCOMDataLinkDesc *const scom)
uint32_t framesReceived
Number of frames that were received since the SCOM connection was opened. In case of multi-frames...
uint32_t framesSent
Number of frames that were sent since the SCOM connection was opened. In case of multi-frames, each sub-frame is counted.
SCOMResult SCOM_SendAllocatedFrame(SCOMDataLink scom, SCOMFrame *frame)
SCOMResult SCOM_RunProcessingThread(SCOMDataLink scom)
SCOMResult SCOM_SendFrameWithoutAck(SCOMDataLink scom, uint8_t framePriority, uint8_t frameType, const void *frameData, uint8_t frameDataSize)
SCOMResult SCOM_SendAllocatedMultiFrame(SCOMDataLink scom, SCOMFrame *frame, SCOMMultiFrameDesc *multiFrameDesc)
SCOMResult SCOM_SendMultiFrame(SCOMDataLink scom, uint8_t framePriority, uint8_t frameType, const void *frameData, uint32_t frameDataSize, SCOMMultiFrameDesc *multiFrameDesc)
uint8_t lastFrameNumber
Counter holding the number of retransmission for a frame that is being currently sent.
void(* ackHandler)(struct SCOMDataLinkDesc *scom, uint8_t frame_type)
Frame reception handler function.
uint8_t verHi
version high number
uint32_t sendTime
CRC of the last received frame.
uint8_t serviceCount
SCOM device identity.
SCOMConnectionState SCOM_GetConnectionState(const SCOMDataLinkDesc *const scom)
uint32_t receptionTime
Transmitted frame send time.
SCOMDataLink SCOM_Create(void)
OSMutex accessGuard
SCOM statistics.
void(* SCOMServiceHandler)(SCOMDataLinkDesc *scom, SCOMFrame *frame)
Definition of the frame buffer used by SCOM.
Descriptor of the ACK state.
Definition of a SCOM frame queue.
SCOMStatistics stats
ACK reception handler function (used only in monitor mode)
SCOMStatistics SCOM_GetStatistics(const SCOMDataLinkDesc *const scom)
uint8_t verLo
version low number
SCOMFrameBuffer * frameBuffer
monitor mode indication (when true - monitor mode is on, the device does not transmit anything...
SCOMReceiverState rxState
Overall state of the connection.
#define SCOM_MAX_FRAME_FILTERS
SCOMResult SCOM_SendAllocatedFrameWithoutACK(SCOMDataLink scom, SCOMFrame *frame)
SCOMResult SCOM_AllocFrame(SCOMDataLink scom, SCOMFrame **framePtr)
SCOMFrameBuffer * SCOM_CreateFrameBuffer(size_t rxBuffSize, size_t txBuffSize)
SCOMConnectionState connectionState
Number of services supported by this instance of SCOM.