AIDA_tstEvent

The AIDA_tstEvent structure is used within all communication functions of the AIDA system. There are various types of events that belong to three groups: Events that may only be generated by the application (AIDA_nenTransmitData), events that may only be generated by the AIDA system (AIDA_nenTransmitDataDone, AIDA_nenReceiveData) and events that may be generated by either by the application to control or configure the AIDA system or by the AIDA system to report status information to the application.

typedef struct {
  AIDA_tenEventType     enEventType;
  byte                   bStackLevel;
  byte                   bEnvironment;
  byte			 bEventsLost;
  byte                   bReserved[1];
  dword                 dwEventID;
  tstTimeVal            stTimeStamp;
  dword                 dwFlags;
  union {
    AIDA_tstParamListA *pstParListA;
    AIDA_tstParamListW *pstParListW;
  } unAttachment;
  union {
    struct {
      tstQword  stSrcID;
      tstQword  stDstID;
      byte       bFlags;
      byte       bUpdateFlags;
      byte       bReserved[1];
      byte       bDataFlags;
      dword     dwDataSize;
      void     *pvData;
      byte      bReserved2[2];
      word      wCycleCount;
      tstTimeVal
               stCycleTime;
    } stData;
    struct {
      dword     dwStatusSize;
      dword     dwEntries;
      struct AIDA_tstStatusHeader *pstStatus;
    } stStatus;
    tstTimeVal stTime;
  } unEventData;
} AIDA_tstEvent;

Members

The members enEventType, bStackLevel, stTimeStamp, dwFlags and unAttachment are filled in by the AIDA system and may not be modified directly by the application.

enEventType
This member of the type AIDA_tenEventType defines the type of an AIDA event. Possible values are AIDA_nenReceiveData, AIDA_nenTransmitData, AIDA_nenTransmitDataDone, AIDA_nenStatus and AIDA_nenTimer.

Note: Events of the type AIDA_nenStatus can also be sent by the application to pass the flags AIDA_nStartCommu, AIDA_nStopCommu or AIDA_nSendBreak to an AIDA stack without transferring data. Depending on the components used in a stack the behaviour of the stack may differ depending on the application sending either a status event or a transmit data event with data size set to 0.
bStackLevel
The bStackLevel member defines the stacklevel where the AIDA event comes from/has to be passed to.
bEnvironment
The bEnvironment member defines if the event was created under an ASCII or UNICODE environment. This member is normally not of any interest for the application.
bEventsLost
The bEventsLost member is valid only when the flag AIDA_nRecvQueueOverrun is set and indicates the events that have been lost. A value of 255 indicates that at least 255 messages have been lost or that the component could not determine the exact number of lost events.
dwEventID
dwEventID is a member the application can use to store private data. dwEventID is inherited by any other event that is derived from the given event (e. g. a transmit data done event carries the event id of the original transmit data event). AIDA_pstCreateEvent initializes this member with a value uniquely identifying the created event on the given stack level for the time this event lives. A range of special event ids is defined for certain update, recall and cyclic operations. The range for these special event ids is chosen so that special event ids will not accidentially generated by AIDA_pstCreateEvent.

The following macros are defined to operate on event ids:

AIDA_boIsSpecialEventID

Available masks for special event ids are:

AIDA_nSpecialEventIDMask
AIDA_nCyclicEventIDMask

The following values for the masked part of special ids are defined:

AIDA_nCyclicEventID
AIDA_nAllEventsID
AIDA_nAllStdEventsID
AIDA_nAllCyclicEventsID

AIDA_boIsSpecialEventID returns true when a special event id is passed as argument. All other masks and values are applicable only for such special event ids.

AIDA_nSpecialEventIDMask can be used to extract the additional information from a special event id.

AIDA_nCyclicEventIDMask can be used to extract the cyclic flag from a special event id.

AIDA_nCyclicEventID is a flag that can be set for cyclic events. Please note that the AIDA stacks do not use this flag for marking and detecting cyclic events. Furthermore there is no way for AIDA_pstCreateEvent to automatically set this flag. So it is up to the application to change the event id after creation if necessary. It is ok to simply or AIDA_nCyclicEventID into the automatically created event id. Note that cyclic event ids are not within the range of special event ids.

AIDA_nAllEventsID may only be used in an event recall operation and matches all events for recall.

AIDA_nStdEventsID - like AIDA_nAllEventsID, but matches only non-cyclic events.

AIDA_nCyclicEventsID - like AIDA_nAllEventsID, but matches only cyclic events.

stTimeStamp
The stTimeStamp member contains an absolute time value in case of received events. AIDA_boSendEvent accepts both relative and absolute time values.
dwFlags
The dwFlags member contains information about the status of the connection the event was generated by or has to be sent to.

Flags for transmit events are:

AIDA_nStartCommu
AIDA_nStopCommu
AIDA_nSendBreak
AIDA_nSynchronize

Flags in receive events are:

AIDA_nCommuStarted
AIDA_nCommuStopped
AIDA_nBreakReceived
AIDA_nMoreFrags
AIDA_nNegativeResponse
AIDA_nUnexpectedData

Warning Flags in receive events are:

AIDA_nSendWarning
AIDA_nRecvWarning

Error flags in receive events are:

AIDA_nSendError
AIDA_nRecvError
AIDA_nCommuStartError
AIDA_nCommuStopError
AIDA_nIllegalID
AIDA_nOverrun
AIDA_nChecksumError
AIDA_nTimeout
AIDA_nInterrupted
AIDA_nFramingError
AIDA_nNegativeResponse
AIDA_nRecvQueueOverrun

Available masks are:

AIDA_nHints
AIDA_nErrors

AIDA_nStartCommu when used in a transmit event tells the AIDA system that the communication with the destination equipment may be started if necessary. If not set the AIDA system reports an error if the communication channel to the destination equipment is closed.

AIDA_nStopCommu when used in a transmit event tells the AIDA system that the communication with the destination equipment shall be stopped if possible.

AIDA_nSendBreak sends a "break" (not supported in every component).

AIDA_nSynchronize has a slightly different meaning for non-cyclic and cyclic events. When used in a non-cyclic transmit event indicates that when the component at the given stacklevel processes this event its time stamp has to be adjusted relative to the previous non-cylic event. When the previous event had been processed in time nothing happens. If the processing the previous event had been delayed e. g. because of a system overload or early e. g. because of the imprecise Windows time measurement the time stamp the current event will be corrected accordingly. The processing interval between the last and the current non-cyclic event will be no smaller than the difference of their time stamps. This may become important in case of CAN transport protocols or when slow gateways exist between the tester and the ECU. In case of cyclic events AIDA_nSynchronize switches between long-term stability (AIDA_nSynchronize not set) and minimum interval (AIDA_nSynchronize set). In case of AIDA_nSynchronize the transmission for the next cycle will be reschecduled when the transmit data done event is received. So the cycle time is the minimum time between end of transmission and the start of the next one. In case of long-term stable mode (AIDA_nSynchronize not set) the transmissions may follow in faster succession than indicated by stCycleTime if delays on previous transmissions had happened. To avoid queue overflows there is a maximum delay of 10 times the cycle time allowed. If the actual delay becomes greater all outstanding cycles will be skipped (and not be counted) and the event will be rescheduled for a time of stCycleTime in the future.

AIDA_nCommuStarted when set in a receive event indicates that the connection to the attached equipment has been (re)opened.

AIDA_nCommuStopped when set in a receive event indicates that the connection to the attached equipment has been closed.

AIDA_nBreakReceived indicates that a "break" has been received. When the event also contains data this data has been received after the break.

AIDA_nMoreFrags indicates that the received data is fragmented and that more data will be transferred in the following receive data events.

AIDA_nNegativeResponse when set indicates that a negative response from an ECU occured, e. g. the command is not implemented or the command or its parameters were invalid.

AIDA_nUnexpectedData when set indicates that data events have been received by the component while there weren't awaited any (e. g. when data is received in half duplex components while there is no pending request). Note: This flag typically does not indicate that the data in the current event is unexpected but that some additional data received before had been dropped.

AIDA_nSendWarning indicates that a problem occured when trying to send data. The stack is still operational. An example for the occurence of this bit is the CAN single wire operation. This flag may occur in data events.

AIDA_nRecvWarning indicates that a problem occured when receiving data. The stack is still operational. An example for the occurence of this bit is the CAN single wire operation. This flag may occur in data events.

AIDA_nSendError indicates that an error occured when trying to send data. This error may occur in various events.

AIDA_nRecvError indicates that an error occured when receiving data. This error may occur in various events.

AIDA_nCommuStartError when set in a receive event indicates that the connection to the attached equipment could not be opened.

AIDA_nCommuStopError when set in a receive event indicates that the connection to the attached equipment could not be closed.

AIDA_nIllegaID when set indicates that one of the IDs was not accepted by the AIDA stack.

AIDA_nOverrun when set indicates that a buffer overrun occured.

AIDA_nChecksumError when set indicates that a checksum error occured.

AIDA_nTimeout when set indicates that a timeout occured (when a half duplex component sets this flag within a receive event this means no answer had been received for a request).

AIDA_nInterrupted when set indicates that a send or receive operation had been interrupted.

AIDA_nFramingError when set indicates that a framing error occured.

AIDA_nParityError when set indicates that parity information is corrupted (e. g. COM component, receive data events).

AIDA_nCollision when set indicates that a collision occurred (e. g. multiple senders are transmitting simultaneously on a shared bus).

AIDA_nRecvQueueOverrun when set indicates that the number of events given in bEventsLost have been lost because a higher component did not empty the receive queue.

AIDA_nHints can be used to test for the hint part of dwFlags.

AIDA_nErrors can be used to test for the error part of dwFlags.

unAttachment
unAttachment contains a pointer to the first element of a linked list of AIDA_tstParamList structures (either wide character or standard versions depending on the environment). If the stSrcID and stDstID members are not sufficient to characterize a specific event a list of parameters for various stack levels may be attached to an event. When attached to a transmit event the change of parameters may either be temporary or permanent. In receive events the parameter attachment contains parameters that were currently set when the event was created. When unAttachment contains a NULL pointer the event does not contain a parameter attachment.
unEventData
unEventData contains data dependent on the type of an event. stData is used in events of the types AIDA_nenReceiveData, AIDA_nenTransmitData and AIDA_nenTransmitDataDone, stStatus is used in events of the type AIDA_nenStatus and stTime is used in events of the type AIDA_nenTimer.
Members of stData
stSrcID
This member may be used by either the application or the AIDA system when the communication channel is not a point-to-point connection and more data is needed to chracterize an event. In transmit events stSrcID contains the address of the application, in receive events it contains the address of the attached equipment. stSrcID will only be evaluated when the flag AIDA_nSrcIDValid in the bFlags member is set.
stDstID
This member may be used by either the application or the AIDA system when the communication channel is not a point-to-point connection and more data is needed to chracterize an event. In transmit events stDstID contains the address of the attached equipment, in receive events it contains the address of the application. stDstID will only be evaluated when the flag AIDA_nDstIDValid in the bFlags member is set.
Cyclic events will not be removed from the transmit queue once they are processed. Instead a clone is generated and passed to the component. The original events stays in the queue until it is recalled, updated to a non-cyclic event or the configured number of cycles (if not infinite) has been reached.
bFlags
This member contains validity information for stSrcID, stDstID and bDataFlags, furthermore a flag for cyclic events. When none of these members are valid and the event is a non-cyclic event bFlags must be set to 0. Otherwise it may have the value AIDA_nSrcIDValid, AIDA_nDstIDValid, AIDA_nDataFlagsValid or AIDA_nCyclic or any combination of these.
bUpdateFlags
If this member has a value other than 0 the event is an update or recall event. This is only allowed for events of type AIDA_nenTransmitData. bUpdateFlags is split into three parts, an enumerated part for the update operation, an enumerated part for the data update operation and some flags.

The following masks are available to separate the parts:

AIDA_nUpdateModeMask
AIDA_nUpdateDataCtrlMask

The following values are available for the UpdateMode part:

AIDA_nUpdateEvent
AIDA_nRecallEvent

The following values are available for the UpdateDataCtrl part:

AIDA_nUpdateDataCtrlAll
AIDA_nUpdateDataCtrlByFlags
AIDA_nUpdateDataCtrlAndFlagsByFlags

The following flags are available for event updates:

AIDA_nUpdateData
AIDA_nUpdateTimeStamp
AIDA_nUpdateFlags
AIDA_nUpdateAttachment

AIDA_nUpdateEvent must be set to indicate an update operation. The dwEventID member must be set to a standard event id. The other parts of bUpdateFlags contain information about which parts of the original event shall be updated. If no event with a corresponding id or more than one event with the corresponding id can be found in the stack the update operation fails and AIDA_boSendEvent will return false.

AIDA_nRecallEvent must be set to indicate an recall operation. The dwEventID member can either be set to a standard event id in which case it will only match exactly one event with this id in the stack or it can be set to one of the special event id values of AIDA_nAllEventsID, AIDA_nAllStdEventsID or AIDA_nAllCyclicEventsID. In case of a standard event id it is an error to have more than one event with the same id in the stack. If dwEventID is set to AIDA_nAllEventsID all events will be recalled, if dwEventID is set to AIDA_nAllStdEventsID or AIDA_nAllCyclicEventsID either all non-cyclic or all cyclic events will be recalled.

AIDA_nUpdateDataCtrlAll indicates an update of all members of the stData member.

AIDA_nUpdateDataCtrlByFlags indicates an update of all members of the stData member where the corresponding validity flags in the bFlags member are set. When AIDA_nCyclic is set the cycle time and cycle count will be updated. Note that bFlags itself will not be updated to the new value.

AIDA_nUpdateDataCtrlAndFlagsByFlags works like AIDA_nUpdateDataCtrlByFlags except that also the bFlags member will be updated.

AIDA_nUpdateData indicates an update of the dwDataSize member and the event data in pvData. Please note that increasing the dwDataSize member leads to an reallocation of the original event memory. As in the current AIDA stacks version the event ids are derived from the memory address of the newly created event the event id may be reused after reallocation. So it is advisable to create an event with varying data size with the maximum data size needed and to set the dwDataSize member to the actual size after the first creation. As the event id generation may change in future versions of the AIDA stacks this step may no longer necessary in the future.

AIDA_nUpdateTimeStamp indicates an update of the stTimeStamp member.

AIDA_nUpdateFlags indicates an update of the dwFlags member.

AIDA_nUpdateAttachment indicates an update of the unAttachment member.

bDataFlags
This member may contain hardware or protocol specific information. bDataFlags will only be evaluated when the flag AIDA_nDataFlagsValid in the bFlags member is set.
dwDataSize
This member specifies the size of the attached data of a transmit or receive event in units of byte. The application may modify this member only under the condition that the new size stored by the application is smaller than the old size. dwSize will be set up when the event is created so there is in general no need to modify its value. dwDataSize must be less than 0x40000000UL due to restrictions in the marshaling library used e. g. in the Net component.
pvData
This member points to a buffer where the data of a transmit or receive event is stored. The application may modify the contents of this buffer but is not allowed to modify pvData. pvData is set up when a transmit or receive event is created.
wCycleCount
This member only is used for cyclic events. When this member is set to 0 the cyclic event never expires. When set to a value other than 0 the value indicates the number of cycles to be done. When the cycle counter has reached a value of 1 no more copy of the event is created when processing starts. In this case this will be the last transmission of the event. The copies of the event passed to the application on each cycle contains the current cycle counter. A value of 1 indicates the last cycle.
stCycleTime
This member is only be used for cyclic events and indicates the cycle time. It has to be a relative time and must not be equal to OSAL_stTimeoutInfinite. The exact interpretation of stCycleTime depends on the flag AIDA_nSynchronize.
Members of stStatus
dwStatusSize
This member indicates how much memory is reserved for status information blocks. dwStatusSize must be less than 0x40000000UL due to restrictions in the marshaling library used e. g. in the Net component.
dwEntries
This member contains the number of status information blocks included in this event.
pstStatus
This member points to the first status information structure. The official way to retrieve this and the pointers to the following status blocks is to use the macro AIDA_pstGetNextStatusHeader. The following status information structures are defined:
typedef struct {
  AIDA_tenStatusType enType;
  dword              dwSize;
} AIDA_tstStatusHeader;

typedef struct {
  AIDA_tenStatusType enType;
  dword              dwSize;
  dword              dwFlags;
} AIDA_tstStackStatus;

typedef struct {
  AIDA_tenStatusType enType;
  dword              dwSize;
  tstTimeVal         stTimeout;
} AIDA_tstRestartRXTimeoutStatus, AIDA_tstRestartTXTimeoutStatus;
AIDA_tstStatusHeader
This is a generic structure that can be used to access the members common to all status information structures.
AIDA_tstStackStatus
Passes the current stack status. enType is set to AIDA_nenStackStatus, dwSize contains the size of the structure and dwFlags contains the status flags. Possible values of these flags are:

AIDA_nStackComplete
AIDA_nStackOnline
AIDA_nStackForcedOffline
AIDA_nInvalidStatus

AIDA_nStackComplete is set when the stack is complete and can be set to online state.

AIDA_nStackOnline is set when the stack is online, that means the hardware driver component has opened a communication port.

AIDA_nStackForcedOffline is set when the stack is forced offline by the application.

AIDA_nInvalidStatus indicates that the dwFlags member is invalid and should normally not be seen by the application.

AIDA_tstRestartRXTimeoutStatus, AIDA_tstRestartTXTimeoutStatus
These are usually used by half duplex components. enType is either AIDA_nenRestartTXTimeoutStatus or AIDA_nenRestartTXTimeoutStatus depending on the type of the status block, dwSize contains the size of the structure and stTimeout contains a relative time to be used as new timeout value.
Members of stTime
dwNSec
dwMSec
The members of stTime contain a time value as described for the datatype tstTimeVal. When the application creates an AIDA_nenTimer event stTime contains the interval in which the AIDA system shall generate timer events. The stTime member must contain a relative time (bit 31 in member dwNSec must be set) otherwise the Event will be ignored. To stop generation of AIDA_nenTimer events the value of stTime has to be set to AIDA_stTimeoutInfinite. After sending this event the AIDA system will restart its timer event generation counter and will create an AIDA_nenTimer event immediately. The AIDA system may modify the interval to meet certain restrictions of the unerlaying operating system. When the application receives a timer event from the AIDA system stTime contains the current interval.

The resolution of stTime is 1ns but the effective resolution may be worse. When bit 31 of dwNSec is not set stTime does not contain a valid time value.

The timers in different AIDA components are not synchronized. This means that timestamps of events of different stacks or different stack levels are not comparable. There is no way to avoid this since an AIDA stack may be splitted over various systems (e. g. when a network component is used in a stack).

See Also

AIDA Overview, AIDA Structures And Datatypes, AIDA_tenEventType, AIDA_tstParamList