/**
*
* tCANFDData structure
*
* @file
* Copyright © Audi Electronic Venture GmbH. All rights reserved
*
* $Author: EWEIRAE $
* $Date: 2015-11-01 14:30:25 +0200 (Mi, 08 Jul 2015) $
* $Revision: 37491 $
*
* @remarks
*
*/
#ifndef _CANFD_TYPES_HEADER_
#define _CANFD_TYPES_HEADER_
#include "can_types.h"
namespace adtf_devicetb
{
/// object identifier for the raw can fd media sample with the default class implementation
/// adtf_devicetb::cMediaSampleCanFD
#define OID_ADTF_MEDIA_SAMPLE_CANFD "adtf.sample.canfd_message"
/// object identifier for the raw can fd media type (see class adtf_devicetb::IMediaTypeCANFD).
#define OID_ADTF_MEDIA_TYPE_CANFD "adtf.type.canfd"
/// interface identifier for the can fd media type (see interface adtf_devicetb::IMediaTypeCANFD).
#define IID_ADTF_MEDIA_TYPE_CANFD "iid.type_canfd"
/// sub type for new can fd data (major Type is MEDIA_TYPE_CAN 0x0200)
#define MEDIA_SUBTYPE_CANFD_DATA 0x0004
/**
* The ADTF Default CANFD Media Type description of adtf_devicetb::tADTFMediaTypeCANFD structure in
* DDL Version 1.0+.
* @see ADTF_MEDIA_DESC_MEDIATYPE_CANFD
*/
#define ADTF_MEDIA_DESC_MEDIATYPE_CANFD_DDL1 "" \
ADTF_MEDIA_DESC_MEDIA_TYPEINFO_DDL1 \
" " \
" " \
" " \
" " \
""
/**
* The ADTF Default CAN FD Media Type description.
* @see ADTF_MEDIA_DESC_MEDIATYPE_CANFD_DDL1
*/
#define ADTF_MEDIA_DESC_MEDIATYPE_CANFD ADTF_MEDIA_DESC_MEDIATYPE_CANFD_DDL1
/**
* This Macro is the type name of the adtf_devicetb::tCANFDData to describe media samples
* submitted on a pin (adtf::IPin).
* Set these description on the Media Type (adtf::IMediaTypeDescription of the IMediatype set on pin).
*/
#define ADTF_MEDIA_DESC_CANFDDATA "tCANFDData"
/**
* This Macro defines the description of a adtf_devicetb::tCANFDData structure
* used within CAN FD MediaSamples of type OID_ADTF_MEDIA_SAMPLE_CANFD
* used for ADTF_MEDIA_DESC_CANFDMESSAGE_DESCRIPTION in Version 1.0+.
*/
#define ADTF_MEDIA_DESC_CANFDDATA_DESCRIPTION_DDL1 "" \
" " \
" " \
" " \
" " \
" " \
" " \
" " \
" " \
" " \
" " \
""
/**
* This Macro defines the description of a adtf_devicetb::tCANFDData structure
* used within CAN MediaSamples of type OID_ADTF_MEDIA_SAMPLE_CANFD
* used for ADTF_MEDIA_DESC_CANFDMESSAGE_DESCRIPTION in Version 2.0.
*/
#define ADTF_MEDIA_DESC_CANFDDATA_ENUM_DDL2 "" \
"" \
"" \
"" \
"" \
"" \
"" \
"" \
"" \
"" \
"" \
"" \
""
#define ADTF_MEDIA_DESC_CANFDDATA_DESCRIPTION_DDL2 ""\
""\
ADTF_MEDIA_DESC_CANFDDATA_ENUM_DDL2 \
""\
"" \
" " \
" " \
" " \
" " \
" " \
" " \
" " \
" " \
" " \
" " \
""\
""\
""
/**
* This Macro defines the description of a adtf_devicetb::tCANFDData structure
* used within ADTF adtf::cMediaSampleCanFD.
* @see ADTF_MEDIA_DESC_CANFDMESSAGE_DESCRIPTION_DDL2.
*/
#define ADTF_MEDIA_DESC_CANFDDATA_DESCRIPTION ADTF_MEDIA_DESC_CANFDDATA_DESCRIPTION_DDL2
#pragma pack(push, 1)
/**
* The Default structure that describe the ADTF CAN FD Type cMediaTypeCANFD.
* The Media Description of this structure is defined within Macro ADTF_MEDIA_DESC_MEDIATYPE_CANFD.
*/
struct tADTFMediaTypeCANFD
{
/// Default media type
adtf::tMediaTypeInfo sMediatype;
/// Symbolic name of the channel
tChar strChannelID[256];
};
/**
* The CAN FD Type Interface extends the default adtf media type
* to add CAN FD specific data descriptions.
*
* Interface Identifier (IID) | IID_ADTF_MEDIA_TYPE_CANFD |
*
*/
class IMediaTypeCANFD : virtual public adtf::IMediaType
{
public:
/**
* Set the symbolic name of the channel
* @param strChannelID [in] New symbolic name
* @result Standard Result Code
*/
virtual tResult SetChannelID(const char* strChannelID) = 0;
/**
* Returns the current symbolic name of the channel
* @result Pointer to symbolic name
*/
virtual const tChar* GetChannelID() const = 0;
};
/**
* The CAN FD data structure is used by CAN FD MediaSamples of type OID_ADTF_MEDIA_SAMPLE_CANFD
* use following code within your filter:
* \code
*
* //...
* cObjectPtr pCANFDSample;
* RETURN_IF_FAILED(AllocMediaSample((tVoid**)&pCANFDSample, OID_ADTF_MEDIA_SAMPLE_CANFD, IID_ADTF_MEDIA_SAMPLE));
* adtf_devicetb::tCANFDData sCANFDMessage;
*
* //... fill your CAN message with the data
*
* RETURN_IF_FAILED(pCANFDSample->Update(_clock->GetStreamTime(), &sCANFDMessage, sizeof(tCANFDData), 0));
*
* //...
*
*
* \endcode
*
*/
struct tCANFDData
{
/**
* This enum specifies the different kinds of messages
* that may be contained in the union
*/
enum eMessageTag
{
MT_Data = 0, //!< Data
MT_Status = 1, //!< Status
};
/**
* CAN FD message flags
*/
enum eDataFlags
{
DF_NONE = 0 //!< Standard flags
, DF_ERROR_FRAME = 1 //!< Indicates an error frame
, DF_REMOTE_FRAME = 2 //!< Indicates a remote frame
, DF_TX_COMPLETED = 4 //!< Notification for successful message transmission
, DF_EXTENDED_DATA_LENGTH = 8 //!< Indicates FlexibleData-Rate (FDF Flexible Datarate Format Indicator)
, DF_CAN_FD_FORMAT_IDENTIFIER = DF_EXTENDED_DATA_LENGTH //!< same as Extended Data Length
, DF_BAUD_RATE_SWITCH = 16 //!< Indicates that the Message uses Flexible Datarate
, DF_SET_CAN_FD_AND_BRS = DF_CAN_FD_FORMAT_IDENTIFIER | DF_BAUD_RATE_SWITCH //!< Helper to Set Extended Data Length and Baud Rate Switch at once
, DF_ERROR_STATE_INDICATOR = 32 //!< EDI Bit Indicates an Error-active state at the CAN FD Node
};
/**
* CAN FD bus state flags.
*/
enum eBusStatus
{
BS_OFFLINE = 1, //!< Bus is offline
BS_ERROR_PASSIVE = 2, //!< One of the error counters has reached the error level.
BS_ERROR_WARNING = 4, //!< One of the error counters has reached the warning level.
BS_ERROR_ACTIVE = 8 //!< Bus is online
};
/**
* CAN FD message id masks. These masks should be used to check for extended or standard messages
* and to get the correct identifier from ui32Id in tData.
*/
enum eMsgId
{
MSG_IDMASK_BASE = 0x000007FF //!< Message IDs for base frame format use 11 bit identifiers
, MSG_IDMASK_EXTENDED = 0x1FFFFFFF //!< Message IDs for extended frame format use 29 bit identifiers
, MSG_EXTENDED_FLAG = 0x80000000 //!< Extended CAN messages are marked by bit 31
};
/**
* CAN FD message header structure
*/
struct tMessageHeader
{
tUInt8 ui8Tag; //!< Type of contained message (see eMessageTag)
tUInt8 ui8Channel; //!< Channel that received this message
tTimeStamp tmTimeStamp; //!< Hardware timestamp in micro seconds
};
/**
* CAN FD message data structure
*/
struct tData
{
tUInt32 ui32Id; //!< id of can message. For extended CAN messages bit 31 is set. Use the members of the enum eMsgId to get the identifier and check for extended messages.
tUInt8 ui8Length; //!< length of data [0..8,12,16,20,24,32,48,64] @attention DLC on Physical layer is coded differently
tUInt8 ui8Reserved; //!< reserved, should be zero
tUInt16 ui16Flags; //!< Flags @see eDataFlags
tUInt16 ui16Reserved; //!< reserved, should be zero
tUInt32 ui32Reserved; //!< reserved, should be zero
tUInt8 aui8Data[64]; //!< data field
};
/**
* CAN FD bus status structure
*/
struct tStatus
{
tUInt32 ui32BitRate; //!< Arbitration or nominal CAN FD bus bitrate
tUInt32 ui32RxBitCount; //!< Count of received bits
tUInt32 ui32TxBitCount; //!< Count of transmitted bits
tUInt16 ui16RxErrorCounter; //!< Error counter for the receive section of the CAN controller.
tUInt16 ui16TxErrorCounter; //!< Error counter for the transmit section of the CAN controller.
tUInt8 ui8BusStatus; //!< Flags @see eBusStatus
tUInt8 ui8Reserved; //!< reserved, should be zero
tUInt32 ui32DataBitRate; //!< alternate Bitrate used for Data in CAN FD messages with BRS flag set.
tUInt8 aui8Reserved[56]; //!< reserved, should be Zero
};
tMessageHeader sHeader; //!< CAN message header structure
union
{
tData sData; //!< used when ui8Tag == MT_Data
tStatus sStatus; //!< used when ui8Tag == MT_Status
};
};
#pragma pack(pop)
} //adtf_devicetb
//*************************************************************************************************
#endif // _CANFD_TYPES_HEADER_