diff options
Diffstat (limited to 'K2LABI/ABI')
-rw-r--r-- | K2LABI/ABI/ABI.cpp | 1138 | ||||
-rw-r--r-- | K2LABI/ABI/ABI.h | 80 | ||||
-rw-r--r-- | K2LABI/ABI/ABICommands.cpp | 1426 | ||||
-rw-r--r-- | K2LABI/ABI/ABICommands.h | 563 | ||||
-rw-r--r-- | K2LABI/ABI/ABICommandsEx.cpp | 4813 | ||||
-rw-r--r-- | K2LABI/ABI/ABICommandsEx.h | 1158 | ||||
-rw-r--r-- | K2LABI/ABI/ABIFilter.cpp | 190 | ||||
-rw-r--r-- | K2LABI/ABI/ABIFilter.h | 81 | ||||
-rw-r--r-- | K2LABI/ABI/ABIFunctionDefinition.h | 254 | ||||
-rw-r--r-- | K2LABI/ABI/Ipc.cpp | 181 | ||||
-rw-r--r-- | K2LABI/ABI/K2LABI.cpp | 25 | ||||
-rw-r--r-- | K2LABI/ABI/K2LABI.h | 1889 | ||||
-rw-r--r-- | K2LABI/ABI/ResultParser.cpp | 29 | ||||
-rw-r--r-- | K2LABI/ABI/ResultParser.h | 13 |
14 files changed, 11840 insertions, 0 deletions
diff --git a/K2LABI/ABI/ABI.cpp b/K2LABI/ABI/ABI.cpp new file mode 100644 index 0000000..61cd29f --- /dev/null +++ b/K2LABI/ABI/ABI.cpp @@ -0,0 +1,1138 @@ +#include <string.h> +#include "ABI.h" +#include "ABIFunctionDefinition.h" +#include "ABICommands.h" + +#define IPC_COMMAND_CHANNEL 0x07 +#define IPC_HEADER_LENGTH 0x06 +#define MAX_RESULT_BUFFER_SIZE (70 * 1024) + + +static void IpcReceiveCallback( const uint8_t * data, uint32_t dataLength, void *cbArg) +{ + if (NULL == cbArg) + { + fprintf(stderr, "IPC receive callback did not provide the given class pointer\n"); + } + CABI *that = (CABI *)cbArg; + if (NULL != that) + { + that->m_pIpcEvents->Decode((BYTE*)data, dataLength); + that->m_pIpcCommands->Decode((BYTE*)data, dataLength); + } +} + +//----------------------------------------------------------------------------- + +CABI::CABI() : + m_dwUniqueId(0xDEADAFFE), + m_bSpyMode(false), + m_pAbiListener(NULL), + m_bStarted(false), + m_pResult(NULL), + m_pIpcCommands(NULL), + m_pIpcEvents(NULL) + +{ + memset(m_objectMap, 0, sizeof(void*) * MAX_CONTEXT_OBJECT); + m_requestEvent.create(); +} + +//----------------------------------------------------------------------------- + +CABI::~CABI() +{ + m_requestEvent.close(); + CIpcFactory::DestroyIpc(m_pIpcCommands); + m_pIpcCommands = NULL; + CIpcFactory::DestroyIpc(m_pIpcEvents); + m_pIpcEvents = NULL; +} + +//----------------------------------------------------------------------------- + +int CABI::Init (AbiIpcDevice* abiDevice, int prio) +{ + int ret = Init(abiDevice); + if(NULL != m_abiDevice) + { + m_abiDevice->SetReceivePriority(prio); + } + return ret; +} + +//----------------------------------------------------------------------------- + +int CABI::Init(AbiIpcDevice* abiDevice) +{ + int nErr = 0; + m_abiDevice = abiDevice; + if (NULL == m_abiDevice) + return -1; + + m_abiDevice->SetReceiveCallback(IpcReceiveCallback, this); + + if(m_pIpcCommands == NULL) + { + m_pIpcCommands = CIpcFactory::CreateIpc(); + nErr = m_pIpcCommands->Init(this); + if (nErr) + return nErr; + } + + if(m_pIpcEvents == NULL) + { + m_pIpcEvents = CIpcFactory::CreateIpc(); + nErr = m_pIpcEvents->Init(this); + if (nErr) + return nErr; + } + + m_dwUniqueId = 0xAffe; + + int resultLen = 0; + BYTE error = 0; + BYTE* pRes = SendRequest((BYTE)Board, (BYTE)FunId__GetSerialNumber, NULL, 0, resultLen, error, 1000); + EndRequest(); + + if (!pRes || error != 0) + return -1; + + return nErr; +} + +//----------------------------------------------------------------------------- + +int CABI::Deinit(void) +{ + CSafeLock safeLock(&m_lock); + delete [] m_pResult; + m_pResult = NULL; + m_nResultLength = 0; + m_errorCode = 0; + + if (m_pIpcCommands != NULL) + { + m_pIpcCommands->Deinit(); + CIpcFactory::DestroyIpc(m_pIpcCommands); + m_pIpcCommands = NULL; + } + + if (m_pIpcEvents != NULL) + { + m_pIpcEvents->Deinit(); + CIpcFactory::DestroyIpc(m_pIpcEvents); + m_pIpcEvents = NULL; + } + + return 0; +} + +//----------------------------------------------------------------------------- + +void CABI::Start(IABIListener* pListener) +{ + CSafeLock safeLock(&m_lock); + m_bStarted = true; + m_pAbiListener = pListener; +} + +//----------------------------------------------------------------------------- + +void CABI::Stop(void) +{ + CSafeLock safeLock(&m_lock); + m_bStarted = false; +} + +//----------------------------------------------------------------------------- + +void CABI::RegisterBusContext(Bus bus, void* context) +{ + m_objectMap[(int)bus] = context; +} + +//----------------------------------------------------------------------------- + +void CABI::UnregisterBusContext (Bus bus) +{ + m_objectMap[(int)bus] = NULL; +} + +//----------------------------------------------------------------------------- + +void* CABI::GetBusContext(Bus bus) +{ + return m_objectMap[(int)bus]; +} + +//----------------------------------------------------------------------------- + +BYTE* CABI::SendRequest(BYTE ifc, BYTE function, BYTE* pData, int nDataLen, int& resultLen, BYTE& errorCode) +{ + return SendRequest(ifc, function, pData, nDataLen, resultLen, errorCode, 3000); +} + +//----------------------------------------------------------------------------- + +BYTE* CABI::SendRequest(BYTE ifc, BYTE function, BYTE* pData, int nDataLen, int& resultLen, BYTE& errorCode, int timeout) +{ + BYTE* pResult = NULL; + resultLen = 0; + errorCode = 0; + + BYTE* pRequest = NULL; + + int nRequestLenNeeded = 0; + int nRequestLen = 0; + //CSafeLock safeLock(&m_lock); + m_lock.lock(); + + if (!m_abiDevice) + return NULL; + + //calculates length of buffer + m_pIpcCommands->FormatRequest(IPC_COMMAND_CHANNEL, ifc, function, m_dwUniqueId, pData, nDataLen, pRequest, 0, &nRequestLenNeeded); + pRequest = new BYTE[nRequestLenNeeded]; + nRequestLen = nRequestLenNeeded; + + //fills buffer with content + int nErr = m_pIpcCommands->FormatRequest(IPC_COMMAND_CHANNEL, ifc, function, m_dwUniqueId, pData, nDataLen, pRequest, nRequestLen, &nRequestLenNeeded); + + if (nRequestLen == nErr) + { + int written = m_abiDevice->Send(pRequest, nRequestLen); + + if (written == nRequestLen) + { + if (!m_requestEvent.waitMsec(timeout)) + { + pResult = m_pResult; + resultLen = m_nResultLength; + errorCode = m_errorCode; + } + } + } + + delete [] pRequest; + pRequest = NULL; + + return pResult; +} + +//----------------------------------------------------------------------------- + +void CABI::EndRequest(void) +{ + m_lock.unlock(); +} + +//----------------------------------------------------------------------------- + +bool CABI::IsSpyMode(void) +{ + return m_bSpyMode; +} + +//----------------------------------------------------------------------------- + +void CABI::SetSpyMode(bool bSpyMode) +{ + m_bSpyMode = bSpyMode; +} + +//----------------------------------------------------------------------------- + +void CABI::OnMessage(IIpc* pIpc, BYTE channel, BYTE errorCode, BYTE* pPacket, int nLen) +{ + if(pIpc == m_pIpcCommands) + { + OnCommandResponse(pIpc, channel, errorCode, pPacket, nLen); + } + else if(pIpc == m_pIpcEvents) + { + OnEvent(pIpc, channel, errorCode, pPacket, nLen); + } + else + { + //Should never be reached. + } +} + +void CABI::OnError(IIpc* pIpc) +{ + if(m_pAbiListener == NULL) + return; + m_pAbiListener->OnError(this); +} + +void CABI::OnMessageLost(IIpc* pIpc) +{ + if(m_pAbiListener == NULL) + return; + m_pAbiListener->OnMessageLost(this); +} + +//----------------------------------------------------------------------------- + +inline void CABI::OnCommandResponse(IIpc* pIpc, BYTE channel, BYTE errorCode, BYTE* pPacket, int nLen) +{ + if (channel != IPC_COMMAND_CHANNEL) + return; + + int requestId = *reinterpret_cast<int*>(pPacket + 2); + + if (requestId != m_dwUniqueId) //Not our request. Will be handled by event thread. + return; + + if (!m_pResult) + m_pResult = new BYTE[MAX_RESULT_BUFFER_SIZE]; + + m_errorCode = errorCode; + m_nResultLength = nLen - IPC_HEADER_LENGTH; + memcpy(m_pResult, pPacket + IPC_HEADER_LENGTH, m_nResultLength); + + m_requestEvent.signal(); +} + +//----------------------------------------------------------------------------- + +inline void CABI::OnEvent(IIpc* pIpc, BYTE channel, BYTE errorCode, BYTE* pPacket, int nLen) +{ + if (channel == IPC_COMMAND_CHANNEL) + return; + + if ((!m_bStarted) || (NULL == m_pAbiListener)) + { + return; + } + + BYTE protocol = (BYTE) (errorCode & 0xF0); + BYTE eventType = (BYTE) (errorCode & 0x0F); + Bus bus = (Bus) (channel + protocol); + + switch(channel & 0xF0u) + { + case 0x00: //Common + DecodeCommon(pPacket, nLen, channel); + break; + case 0x10: //CAN + DecodeCanChannels(pPacket, nLen, bus, protocol, eventType); + break; + case 0x20: //MOST + DecodeMostChannels(pPacket, nLen, bus, protocol, eventType); + break; + case 0x40: //FlexRay + DecodeFlexRayChannels(pPacket, nLen, bus, protocol, eventType); + break; + case 0x50: //LIN + DecodeLinChannels(pPacket, nLen, bus, protocol, eventType); + break; + case 0xB0: //Relay + DecodeRelayChannels(pPacket, nLen, bus, protocol, eventType); + break; + case 0xD0: //MOST Ethernet + DecodeMostEthernetChannels(pPacket, nLen, bus, protocol, eventType); + break; + default: + break; + } +} + +//----------------------------------------------------------------------------- + +inline void CABI::DecodeCommon(BYTE* pPacket, int nLen, BYTE channel) +{ + BYTE* pBuffer = pPacket; + unsigned long long timestamp = ReadUInt64(pBuffer); + + switch(channel) + { + case 0x01: //Internal + { + Parameter parameter = (Parameter) ReadUInt16(pBuffer); + unsigned int param1 = (unsigned int)ReadUInt32(pBuffer); + unsigned int param2 = (unsigned int)ReadUInt32(pBuffer); + + m_pAbiListener->OnInternalEvent(this, timestamp, parameter, param1, param2); + } + break; + case 0x02: //General + { + unsigned short identifier = ReadUInt16(pBuffer); + unsigned short payloadLength = ReadUInt16(pBuffer); + BYTE* payload = pBuffer; + + m_pAbiListener->OnGeneralEvent(this, timestamp, identifier & 0xFF, payload, payloadLength); + } + break; + case 0x03: //Object State + { + ObjectType type = (ObjectType)ReadByte(pBuffer); + unsigned short handle = ReadUInt16(pBuffer); + BYTE groupId = ReadByte(pBuffer); + ObjectState state = (ObjectState)ReadByte(pBuffer); + Bus bus = (Bus)ReadByte(pBuffer); + + m_pAbiListener->OnObjectStateChanged(this, GetBusContext(bus), timestamp, bus, type, handle, groupId, state); + } + break; + default: + break; + } +} + +//----------------------------------------------------------------------------- + +inline void CABI::DecodeCanChannels(BYTE* pPacket, int nLen, Bus bus, BYTE protocol, BYTE eventType) +{ + BYTE* pBuffer = pPacket; + unsigned long long timestamp = ReadUInt64(pBuffer); + + switch(eventType) + { + case 0x01: //Event + { + TBusEvent evt = (TBusEvent) ReadByte(pBuffer); + + unsigned int param1 = (unsigned int)ReadUInt32(pBuffer); + unsigned int param2 = (unsigned int)ReadUInt32(pBuffer); + switch (evt) + { + case beCANBusError: + m_pAbiListener->OnCanBusError(this, GetBusContext(bus), timestamp, bus, evt, (TCanError)param1); + break; + default: + m_pAbiListener->OnCanEventMessage(this, GetBusContext(bus), timestamp, bus, evt, param1, param2); + break; + } + } + break; + case 0x02: //Tx + { + bool isExtendedCAN = false; + if(0 < protocol) + isExtendedCAN = true; + + BYTE status = ReadByte(pBuffer); + /*BYTE param2 = */ReadByte(pBuffer); + unsigned short handle = ReadUInt16(pBuffer); + /*unsigned short target = */ ReadUInt16(pBuffer); + unsigned int messageId = (unsigned int)ReadUInt32(pBuffer); + + if (!m_filter.Match(bus, messageId)) + { + return; + } + + unsigned short payloadLength = ReadUInt16(pBuffer); + BYTE* payload = pBuffer; + + switch(status) + { + case canSuccess: + m_pAbiListener->OnCanTxMessage(this, GetBusContext(bus), timestamp, handle, bus, messageId, isExtendedCAN, payload, payloadLength); + break; + default: + m_pAbiListener->OnCanTxFailedMessage(this, GetBusContext(bus), timestamp, handle, bus, messageId, isExtendedCAN, payload, payloadLength); + break; + } + } + break; + case 0x03: //Rx + { + bool isExtendedCAN = false; + if(0 < protocol) + isExtendedCAN = true; + + /*BYTE param1 = */ReadByte(pBuffer); + /*BYTE param2 = */ReadByte(pBuffer); + /*unsigned short source = */ReadUInt16(pBuffer); + unsigned int messageId = (unsigned int)ReadUInt32(pBuffer); + + if (!m_filter.Match(bus, messageId)) + { + return; + } + + unsigned short payloadLength = ReadUInt16(pBuffer); + BYTE* payload = pBuffer; + + m_pAbiListener->OnCanRxMessage(this, GetBusContext(bus), timestamp, bus, messageId, isExtendedCAN, payload, payloadLength); + } + break; + case 0x04: //Bus Changed Event + { + bool isStarted = (ReadByte(pBuffer) > 0 ? true : false); + m_pAbiListener->OnBusRunningStateChanged(this, GetBusContext(bus), timestamp, bus, isStarted); + } + break; + case 0x05: //Tx Filter Payload Event + { + bool isEnabled = (ReadByte(pBuffer) > 0 ? true : false); + m_pAbiListener->OnTxPayloadFilterChanged(this, GetBusContext(bus), timestamp, bus, isEnabled); + } + break; + case 0x0A: //Tx CAN TP + { + unsigned short handle = ReadUInt16(pBuffer); + unsigned int source = (unsigned int)ReadUInt32(pBuffer); + unsigned int destination = (unsigned int)ReadUInt32(pBuffer); + TPAddressingType addrType = (TPAddressingType) ReadByte(pBuffer); + TPOpResult opTypeResult = (TPOpResult) ReadByte(pBuffer); + + m_pAbiListener->OnCanTpTxMessage(this, GetBusContext(bus), timestamp, handle, bus, source, destination, addrType, opTypeResult); + } + break; + case 0x0B: //Rx CAN TP + { + unsigned short handle = ReadUInt16(pBuffer); + unsigned int source = (unsigned int)ReadUInt32(pBuffer); + unsigned int destination = (unsigned int)ReadUInt32(pBuffer); + TPAddressingType addrType = (TPAddressingType) ReadByte(pBuffer); + TPOpResult opTypeResult = (TPOpResult) ReadByte(pBuffer); + unsigned short payloadLength = ReadUInt16(pBuffer); + BYTE* payload = pBuffer; + + m_pAbiListener->OnCanTpRxMessage(this, GetBusContext(bus), timestamp, handle, bus, source, destination, addrType, opTypeResult, payload, payloadLength); + } + break; + default: + break; + } +} + +//----------------------------------------------------------------------------- + +inline void CABI::DecodeMostChannels(BYTE* pPacket, int nLen, Bus bus, BYTE protocol, BYTE eventType) +{ + BYTE* pBuffer = pPacket; + unsigned long long timestamp = ReadUInt64(pBuffer); + + switch(eventType) + { + case 0x01: //Event + { + TBusEvent evt = (TBusEvent) ReadByte(pBuffer); + unsigned int param1 = (unsigned int)ReadUInt32(pBuffer); + unsigned int param2 = (unsigned int)ReadUInt32(pBuffer); + + m_pAbiListener->OnMostEventMessage(this, GetBusContext(bus), timestamp, bus, evt, param1, param2); + } + break; + case 0x02: //Tx + { + unsigned short status = ReadByte(pBuffer); + /*BYTE param2 = */ReadByte(pBuffer); + unsigned short handle = ReadUInt16(pBuffer); + unsigned short target = ReadUInt16(pBuffer); + unsigned int messageId = (unsigned int)ReadUInt32(pBuffer); + + if (!m_filter.Match(bus, messageId)) + { + return; + } + + unsigned short payloadLength = ReadUInt16(pBuffer); + BYTE* payload = pBuffer; + + switch(protocol) + { + case 0x00: //AMS + status += 0x0100; + switch(status) + { + case mostControlSuccess: + m_pAbiListener->OnMostTxMessage(this, GetBusContext(bus), timestamp, handle, bus, target, AMS, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), payload, payloadLength); + break; + case mostControlRetry: + m_pAbiListener->OnMostTxNAKMessage(this, GetBusContext(bus), timestamp, handle, bus, target, AMS, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), payload, payloadLength); + break; + default: + m_pAbiListener->OnMostTxFailedMessage(this, GetBusContext(bus), timestamp, (MostTxStatus)status, handle, bus, target, AMS, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), payload, payloadLength); + break; + } + break; + + case 0x60: //CMS + status += 0x0100; + switch(status) + { + case mostControlSuccess: + m_pAbiListener->OnMostTxMessage(this, GetBusContext(bus), timestamp, handle, bus, target, CMS, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), payload, payloadLength); + break; + case mostControlRetry: + m_pAbiListener->OnMostTxNAKMessage(this, GetBusContext(bus), timestamp, handle, bus, target, CMS, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), payload, payloadLength); + break; + default: + m_pAbiListener->OnMostTxFailedMessage(this, GetBusContext(bus), timestamp, (MostTxStatus)status, handle, bus, target, CMS, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), payload, payloadLength); + break; + } + break; + + case 0x10: //High + status += 0x0200; + switch(status) + { + case mostAsyncSuccess: + m_pAbiListener->OnMostTxMessage(this, GetBusContext(bus), timestamp, handle, bus, target, HIGH, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), payload, payloadLength); + break; + case mostAsyncErrorNac: + m_pAbiListener->OnMostTxNAKMessage(this, GetBusContext(bus), timestamp, handle, bus, target, HIGH, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), payload, payloadLength); + break; + default: + m_pAbiListener->OnMostTxFailedMessage(this, GetBusContext(bus), timestamp, (MostTxStatus)status, handle, bus, target, HIGH, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), payload, payloadLength); + break; + } + break; + + case 0x70: //ADS + status += 0x0200; + switch(status) + { + case mostAsyncSuccess: + m_pAbiListener->OnMostTxMessage(this, GetBusContext(bus), timestamp, handle, bus, target, ADS, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), payload, payloadLength); + break; + case mostAsyncErrorNac: + m_pAbiListener->OnMostTxNAKMessage(this, GetBusContext(bus), timestamp, handle, bus, target, ADS, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), payload, payloadLength); + break; + default: + m_pAbiListener->OnMostTxFailedMessage(this, GetBusContext(bus), timestamp, (MostTxStatus)status, handle, bus, target, ADS, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), payload, payloadLength); + break; + } + break; + + default: + break; + } + } + break; + case 0x03: //Rx + { + ReceiveType rcvType = (ReceiveType) ReadByte(pBuffer); + BYTE param2 = ReadByte(pBuffer); + unsigned short source = ReadUInt16(pBuffer); + unsigned int messageId = (unsigned int)ReadUInt32(pBuffer); + + if (!m_filter.Match(bus, messageId)) + { + return; + } + + unsigned short payloadLength = ReadUInt16(pBuffer); + BYTE* payload = pBuffer; + + MostRxStatus status = MhpSuccess; + + switch(protocol) + { + case 0x00: //AMS + m_pAbiListener->OnMostRxMessage(this, GetBusContext(bus), timestamp, bus, rcvType, source, AMS, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), payload, payloadLength); + break; + + case 0x60: //CMS + m_pAbiListener->OnMostRxMessage(this, GetBusContext(bus), timestamp, bus, rcvType, source, CMS, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), payload, payloadLength); + break; + + case 0x10: //High + status = (MostRxStatus) (param2 + 0x0200); + switch((MostRxStatus) status) + { + case MhpSuccess: + m_pAbiListener->OnMostRxMessage(this, GetBusContext(bus), timestamp, bus, rcvType, source, HIGH, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), payload, payloadLength); + break; + default: + m_pAbiListener->OnMostRxFailedMessage(this, GetBusContext(bus), timestamp, bus, (MostRxStatus) status, rcvType, source, HIGH, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), payload, payloadLength); + break; + } + break; + + case 0x70: //ADS + m_pAbiListener->OnMostRxMessage(this, GetBusContext(bus), timestamp, bus, rcvType, source, ADS, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), payload, payloadLength); + break; + + default: + break; + } + } + break; + case 0x04: //Bus Changed Event + { + bool isStarted = (ReadByte(pBuffer) > 0 ? true : false); + m_pAbiListener->OnBusRunningStateChanged(this, GetBusContext(bus), timestamp, bus, isStarted); + } + break; + case 0x05: //Tx Filter Payload Event + { + bool isEnabled = (ReadByte(pBuffer) > 0 ? true : false); + m_pAbiListener->OnTxPayloadFilterChanged(this, GetBusContext(bus), timestamp, bus, isEnabled); + } + break; + case 0x0A: //Rx MOST High extended (>64kb) + { + ReceiveType rcvType = (ReceiveType) ReadByte(pBuffer); + BYTE stat = ReadByte(pBuffer); + unsigned short source = ReadUInt16(pBuffer); + unsigned int messageId = (unsigned int)ReadUInt32(pBuffer); + + if (!m_filter.Match(bus, messageId)) + { + return; + } + + BYTE segmentationId = ReadByte(pBuffer); + unsigned short blockCounter = ReadUInt16(pBuffer); + /*BYTE dummy = */ReadByte(pBuffer); + + unsigned short payloadLength = ReadUInt16(pBuffer); + BYTE* payload = pBuffer; + + MostRxStatus status = (MostRxStatus) (stat + 0x0200); + + m_pAbiListener->OnMostHighExtRxMessage(this, GetBusContext(bus), timestamp, bus, status, rcvType, source, HIGH, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), segmentationId, blockCounter, payload, payloadLength); + } + break; + case 0x0B: //Allocation event + { + unsigned int connectionLabel = (unsigned int)ReadUInt32(pBuffer); + AudioConnectionType type = (AudioConnectionType) ReadByte(pBuffer); + AudioBandwidth bandwith = (AudioBandwidth) ReadByte(pBuffer); + bool isOpenEvent = (ReadByte(pBuffer) > 0 ? true : false); + AudioConnectorType connector = (AudioConnectorType) ReadByte(pBuffer); + m_pAbiListener->OnMostAudioStreamingEvent(this, GetBusContext(bus), timestamp, connectionLabel, type, bandwith, isOpenEvent, connector); + } + break; + case 0x0C: //Allocation error event + { + unsigned short errorCode = ReadUInt16(pBuffer); + AudioConnectionType type = (AudioConnectionType) ReadByte(pBuffer); + AudioBandwidth bandwith = (AudioBandwidth) ReadByte(pBuffer); + bool isOpenEvent = (ReadByte(pBuffer) > 0 ? true : false); + AudioConnectorType connector = (AudioConnectorType) ReadByte(pBuffer); + m_pAbiListener->OnMostAudioStreamingError(this, GetBusContext(bus), timestamp, errorCode, type, bandwith, isOpenEvent, connector); + } + break; + case 0x0D: //Allocation table event + { + unsigned short length = ReadUInt16(pBuffer); + AllocationTableEntry* allocationTable = NULL; + if(length > 0) + { + allocationTable = (AllocationTableEntry*) pBuffer; + } + m_pAbiListener->OnMostAllocationTableChanged(this, GetBusContext(bus), timestamp, length, allocationTable); + } + break; + case 0x0E: //MHP status + { + bool isTx = (ReadByte(pBuffer) > 0 ? true : false); + unsigned short status = ReadByte(pBuffer); + unsigned int messageId = (unsigned int)ReadUInt32(pBuffer); + unsigned short address = ReadUInt16(pBuffer); + status = (unsigned short)(status + 0x200); //Add 0x200 for signaling Async Event type + if(isTx) + m_pAbiListener->OnMostHighTxStatusEvent(this, GetBusContext(bus), timestamp, MOST_ASYNC1_HIGH, (MostTxStatus)status, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), address); + else + m_pAbiListener->OnMostHighRxStatusEvent(this, GetBusContext(bus), timestamp, MOST_ASYNC1_HIGH, (MostRxStatus)status, messageId, (BYTE)(messageId >> 24), (BYTE)((messageId >> 16) & 0xFF), (unsigned short)((messageId >> 4) & 0xFFF), (BYTE)(messageId & 0xF), address); + } + break; + case 0x0F: //StressNIC state changed + { + unsigned short deviceId = ReadUInt16(pBuffer); + BYTE fblockId = ReadByte(pBuffer); + BYTE instanceId = ReadByte(pBuffer); + unsigned short functionId = ReadUInt16(pBuffer); + BYTE opType = ReadByte(pBuffer); + /*BYTE reserved = */ReadByte(pBuffer); + unsigned short payloadLength = ReadUInt16(pBuffer); + BYTE* payload = pBuffer; + m_pAbiListener->OnStressNicMessageReceived(this, GetBusContext(bus), timestamp, bus, deviceId, fblockId, instanceId, functionId, opType, payload, payloadLength); + } + break; + default: + break; + } +} + +//----------------------------------------------------------------------------- + +inline void CABI::DecodeLinChannels(BYTE* pPacket, int nLen, Bus bus, BYTE protocol, BYTE eventType) +{ + BYTE* pBuffer = pPacket; + unsigned long long timestamp = ReadUInt64(pBuffer); + + switch(eventType) + { + case 0x01: //Event + { + TBusEvent evt = (TBusEvent) ReadByte(pBuffer); + unsigned int param = (unsigned int)ReadUInt32(pBuffer); + //ignored: ReadUInt32(pBuffer); + + switch(evt) + { + case beLINBusError: + { + TLinError linError = (TLinError) (param & 0xFFu); + m_pAbiListener->OnLinBusError(this, GetBusContext(bus), timestamp, bus, evt, linError); + } + break; + case beLINTPBusError: + { + TLinTpError lintpError = (TLinTpError) (param & 0xFFu); + m_pAbiListener->OnLinTpBusError(this, GetBusContext(bus), timestamp, bus, evt, lintpError); + } + break; + default: + break; + } + } + break; + case 0x02: //Tx + { + BYTE status = ReadByte(pBuffer); + /*BYTE param2 = */ReadByte(pBuffer); + unsigned short handle = ReadUInt16(pBuffer); + unsigned short target = ReadUInt16(pBuffer); + unsigned int messageId = (unsigned int)ReadUInt32(pBuffer); + + if (!m_filter.Match(bus, messageId)) + { + return; + } + + unsigned short payloadLength = ReadUInt16(pBuffer); + BYTE* payload = pBuffer; + + switch(bus) + { + case LIN1: + case LIN2: + case LIN3: + case LIN4: + case LIN5: + case LIN6: + switch(status) + { + case linSuccess: + m_pAbiListener->OnLinTxMessage(this, GetBusContext(bus), timestamp, handle, bus, target, messageId, payload, payloadLength); + break; + default: + m_pAbiListener->OnLinTxFailedMessage(this, GetBusContext(bus), timestamp, handle, bus, target, messageId, payload, payloadLength); + break; + } + break; + case LINTP1: + case LINTP2: + case LINTP3: + case LINTP4: + case LINTP5: + case LINTP6: + switch(status) + { + case linSuccess: + m_pAbiListener->OnLinTpTxMessage(this, GetBusContext(bus), timestamp, handle, bus, messageId, (BYTE)(messageId & 0xFF), (BYTE)((messageId >> 8) & 0xFF), (BYTE)((messageId >> 16) & 0xFF), payload, payloadLength); + break; + default: + m_pAbiListener->OnLinTpTxFailedMessage(this, GetBusContext(bus), timestamp, handle, bus, messageId, (BYTE)(messageId & 0xFF), (BYTE)((messageId >> 8) & 0xFF), (BYTE)((messageId >> 16) & 0xFF), payload, payloadLength); + break; + } + break; + default: + break; + } + } + break; + case 0x03: //Rx + { + /*BYTE param1 = */ReadByte(pBuffer); + /*BYTE param2 = */ReadByte(pBuffer); + unsigned short source = ReadUInt16(pBuffer); + unsigned int messageId = (unsigned int)ReadUInt32(pBuffer); + if (!m_filter.Match(bus, messageId)) + { + return; + } + + unsigned short payloadLength = ReadUInt16(pBuffer); + BYTE* payload = pBuffer; + + switch(bus) + { + case LIN1: + case LIN2: + case LIN3: + case LIN4: + case LIN5: + case LIN6: + m_pAbiListener->OnLinRxMessage(this, GetBusContext(bus), timestamp, bus, source, messageId, payload, payloadLength); + break; + case LINTP1: + case LINTP2: + case LINTP3: + case LINTP4: + case LINTP5: + case LINTP6: + m_pAbiListener->OnLinTpRxMessage(this, GetBusContext(bus), timestamp, bus, messageId, (BYTE)(messageId & 0xFF), (BYTE)((messageId >> 8) & 0xFF), (BYTE)((messageId >> 16) & 0xFF), payload, payloadLength); + break; + default: + break; + } + } + break; + case 0x04: //Bus Changed Event + { + bool isStarted = (ReadByte(pBuffer) > 0 ? true : false); + m_pAbiListener->OnBusRunningStateChanged(this, GetBusContext(bus), timestamp, bus, isStarted); + } + break; + case 0x05: //Tx Filter Payload Event + { + bool isEnabled = (ReadByte(pBuffer) > 0 ? true : false); + m_pAbiListener->OnTxPayloadFilterChanged(this, GetBusContext(bus), timestamp, bus, isEnabled); + } + break; + case 0x0A: //Spy Event + { + TLinSpyEvent spyEvent = (TLinSpyEvent) ReadByte(pBuffer); + m_pAbiListener->OnLinSpyEvent(this, GetBusContext(bus), timestamp, bus, spyEvent); + } + break; + case 0x0B: //Spy Message + { + BYTE payload = ReadByte(pBuffer); + m_pAbiListener->OnLinSpyMessage(this, GetBusContext(bus), timestamp, bus, payload); + } + break; + default: + break; + } +} + +//----------------------------------------------------------------------------- + +inline void CABI::DecodeFlexRayChannels(BYTE* pPacket, int nLen, Bus bus, BYTE protocol, BYTE eventType) +{ + BYTE* pBuffer = pPacket; + unsigned long long timestamp = ReadUInt64(pBuffer); + + switch(eventType) + { + case 0x01: //Event + { + TBusEvent evt = (TBusEvent)ReadByte(pBuffer); + //ignored: ReadUInt32(pBuffer); + //ignored: ReadUInt32(pBuffer); + + m_pAbiListener->OnFlexrayEventMessage(this, GetBusContext(bus), timestamp, bus, evt); + } + break; + case 0x02: //Tx + { + BYTE status = ReadByte(pBuffer); + /*BYTE param2 = */ReadByte(pBuffer); + unsigned short handle = ReadUInt16(pBuffer); + unsigned short target = ReadUInt16(pBuffer); + unsigned int messageId = (unsigned int)ReadUInt32(pBuffer); + + if (!m_filter.Match(bus, messageId)) + { + return; + } + + unsigned short payloadLength = ReadUInt16(pBuffer); + BYTE* payload = pBuffer; + + switch(status) + { + case flexraySuccess: + m_pAbiListener->OnFlexrayTxMessage(this, GetBusContext(bus), timestamp, handle, bus, messageId, (unsigned short)(messageId & 0x7FF), (BYTE)((messageId >> 16) & 0x3F), (BYTE)(((messageId >> 24) & 0x3F) + 1), (FrChannel)((messageId >> 12) & 0x3), target, payload, payloadLength); + break; + default: + m_pAbiListener->OnFlexrayTxFailedMessage(this, GetBusContext(bus), timestamp, handle, bus, messageId, (unsigned short)(messageId & 0x7FF), (BYTE)((messageId >> 16) & 0x3F), (BYTE)(((messageId >> 24) & 0x3F) + 1), (FrChannel)((messageId >> 12) & 0x3), target, payload, payloadLength); + break; + } + } + break; + case 0x03: //Rx + { + /*BYTE param1 = */ReadByte(pBuffer); + /*BYTE param2 = */ReadByte(pBuffer); + unsigned short source = ReadUInt16(pBuffer); + unsigned int messageId = (unsigned int)ReadUInt32(pBuffer); + + if (!m_filter.Match(bus, messageId)) + { + return; + } + + unsigned short payloadLength = ReadUInt16(pBuffer); + BYTE* payload = pBuffer; + + m_pAbiListener->OnFlexrayRxMessage(this, GetBusContext(bus), timestamp, bus, messageId, (unsigned short)(messageId & 0x7FF), (BYTE)((messageId >> 16) & 0x3F), (BYTE)(((messageId >> 24) & 0x3F) + 1), (FrChannel)((messageId >> 12) & 0x3), source, payload, payloadLength); + } + break; + case 0x04: //Bus Changed Event + { + bool isStarted = (ReadByte(pBuffer) > 0 ? true : false); + m_pAbiListener->OnBusRunningStateChanged(this, GetBusContext(bus), timestamp, bus, isStarted); + } + case 0x05: //Tx Filter Payload Event + { + bool isEnabled = (ReadByte(pBuffer) > 0 ? true : false); + m_pAbiListener->OnTxPayloadFilterChanged(this, GetBusContext(bus), timestamp, bus, isEnabled); + } + break; + break; + default: + break; + } +} + +//----------------------------------------------------------------------------- + +inline void CABI::DecodeRelayChannels(BYTE* pPacket, int nLen, Bus bus, BYTE protocol, BYTE eventType) +{ + BYTE* pBuffer = pPacket; + unsigned long long timestamp = ReadUInt64(pBuffer); + + switch (eventType) + { + case 0x04: //Bus Changed Event + { + bool isClosed = ReadByte(pBuffer) > 0; + m_pAbiListener->OnRelayStateChanged(this, GetBusContext(bus), timestamp, bus, isClosed); + } + break; + case 0x0A: //Trigger level changed + { + bool isActive = ReadByte(pBuffer) > 0; + bool isTx = ReadByte(pBuffer) > 0; + m_pAbiListener->OnTriggerLevelChanged(this, GetBusContext(bus), timestamp, bus, isActive, isTx); + } + break; + //case 0x0B: //Timer Elapsed + // { + // unsigned short handle = ReadUInt16(pBuffer); + // m_pAbiListener->OnTimerElapsed(this, GetBusContext(bus), timestamp, bus, handle); + // } + // break; + default: + break; + } +} + +//----------------------------------------------------------------------------- + +inline void CABI::DecodeMostEthernetChannels(BYTE* pPacket, int nLen, Bus bus, BYTE protocol, BYTE eventType) +{ + BYTE* pBuffer = pPacket; + unsigned long long timestamp = ReadUInt64(pBuffer); + + switch (eventType) + { + case 0x02: //Tx + { + unsigned short handle = ReadUInt16(pBuffer); + unsigned long long target = ReadUInt64(pBuffer); + //if (!Filter.MatchAddress(bus, target, ABIFilter.FILTER_TX)) + //{ + // return; + //} + unsigned short payloadLength = ReadUInt16(pBuffer); + BYTE* payload = pBuffer; + m_pAbiListener->OnMostMepTxMessage(this, GetBusContext(bus), timestamp, handle, bus, target, payload, payloadLength); + } + break; + case 0x03: //Rx + { + unsigned long long source = ReadUInt64(pBuffer); + //if (!Filter.MatchAddress(bus, source, ABIFilter.FILTER_RX)) + //{ + // return; + //} + unsigned short payloadLength = ReadUInt16(pBuffer); + BYTE* payload = pBuffer; + m_pAbiListener->OnMostMepRxMessage(this, GetBusContext(bus), timestamp, bus, source, payload, payloadLength); + } + break; + case 0x04: //Bus Changed Event + { + bool isStarted = ReadByte(pBuffer) > 0; + MepBridgeOptions options = (MepBridgeOptions)ReadByte(pBuffer); + m_pAbiListener->OnMostMepBridgeStatusChanged(this, GetBusContext(bus), timestamp, bus, isStarted, options); + } + break; + case 0x05: //Tx Filter Payload Event + { + bool isEnabled = ReadByte(pBuffer) > 0; + m_pAbiListener->OnTxPayloadFilterChanged(this, GetBusContext(bus), timestamp, bus, isEnabled); + } + break; + case 0x0A: //MAC address changed Event + { + unsigned long long macAddress = ReadUInt64(pBuffer); + m_pAbiListener->OnMostMacAddressChanged(this, GetBusContext(bus), timestamp, bus, macAddress); + } + break; + default: + break; + } +} + +//----------------------------------------------------------------------------- + +BYTE CABI::ReadByte(BYTE*& pBuffer) +{ + BYTE ret = pBuffer[0]; + pBuffer++; + return ret; +} + +//----------------------------------------------------------------------------- + +unsigned short CABI::ReadUInt16(BYTE*& pBuffer) +{ + unsigned short ret = *(uint16_t*)pBuffer; + pBuffer += sizeof(uint16_t); + return ret; +} + +//----------------------------------------------------------------------------- + +unsigned long CABI::ReadUInt32(BYTE*& pBuffer) +{ + unsigned long ret = *(uint32_t*)pBuffer; + pBuffer += sizeof(uint32_t); + return ret; +} + +//----------------------------------------------------------------------------- + +unsigned long long CABI::ReadUInt64(BYTE*& pBuffer) +{ + unsigned long long ret = *(unsigned long long*)pBuffer; + pBuffer += sizeof(unsigned long long); + return ret; +} + +//----------------------------------------------------------------------------- + +void CABI::AddIdIntervalFilter(Bus bus, unsigned short handle, unsigned int minId, unsigned int maxId) +{ + m_filter.AddIntervalFilter(bus, handle, minId, maxId); +} + +//----------------------------------------------------------------------------- + +void CABI::AddMaskedIdFilter(Bus bus, unsigned short handle, unsigned int id, unsigned int mask) +{ + m_filter.AddMaskedFilter(bus, handle, id, mask); +} + +//----------------------------------------------------------------------------- + +void CABI::RemoveFilter(unsigned short handle) +{ + m_filter.RemoveFilter(handle); +} diff --git a/K2LABI/ABI/ABI.h b/K2LABI/ABI/ABI.h new file mode 100644 index 0000000..791bb3b --- /dev/null +++ b/K2LABI/ABI/ABI.h @@ -0,0 +1,80 @@ +#pragma once +#include "windows-adapter.h" +#include "K2LABI.h" +#include "K2LIPC.h" +#include "SLock.h" +#include "ABIFilter.h" +#include "SEvent.h" +#define MAX_CONTEXT_OBJECT 256 + +using namespace K2L::Automotive::ABI; +using namespace K2L::Automotive::IPC; + +class CABI : public IABI, public IIPCListener +{ +public: + CABI(); + ~CABI(); + + int Init (AbiIpcDevice* pInitData); + int Init (AbiIpcDevice* pInitData, int prio); + int Deinit (void); + void Start (IABIListener* pListener); + void Stop (void); + void RegisterBusContext (Bus bus, void* context); + void UnregisterBusContext (Bus bus); + void* GetBusContext (Bus bus); + bool IsSpyMode (void); + void SetSpyMode (bool bSpyMode); + BYTE* SendRequest(BYTE ifc, BYTE function, BYTE* data, int len, int& resultLen, BYTE& errorCode); + BYTE* SendRequest(BYTE ifc, BYTE function, BYTE* data, int len, int& resultLen, BYTE& errorCode, int timeout); + void EndRequest(); + + void AddIdIntervalFilter (Bus bus, unsigned short handle, unsigned int minId, unsigned int maxId); + void AddMaskedIdFilter (Bus bus, unsigned short handle, unsigned int id, unsigned int mask); + void RemoveFilter (unsigned short handle); + + void OnMessage(IIpc* pIpc, BYTE channel, BYTE errorCode, BYTE* pPacket, int nLen); + void OnError(IIpc* pIpc); + void OnMessageLost(IIpc* pIpc); +public: + //Will be accessed by the IPC receive callback, which is in static context + IIpc* m_pIpcCommands; + IIpc* m_pIpcEvents; + +private: + inline void OnCommandResponse(IIpc* pIpc, BYTE channel, BYTE errorCode, BYTE* pPacket, int nLen); + inline void OnEvent(IIpc* pIpc, BYTE channel, BYTE errorCode, BYTE* pPacket, int nLen); + + inline void DecodeCommon(BYTE* pPacket, int nLen, BYTE channel); + inline void DecodeCanChannels(BYTE* pPacket, int nLen, Bus bus, BYTE protocol, BYTE eventType); + inline void DecodeMostChannels(BYTE* pPacket, int nLen, Bus bus, BYTE protocol, BYTE eventType); + inline void DecodeLinChannels(BYTE* pPacket, int nLen, Bus bus, BYTE protocol, BYTE eventType); + inline void DecodeFlexRayChannels(BYTE* pPacket, int nLen, Bus bus, BYTE protocol, BYTE eventType); + inline void DecodeRelayChannels(BYTE* pPacket, int nLen, Bus bus, BYTE protocol, BYTE eventType); + inline void DecodeMostEthernetChannels(BYTE* pPacket, int nLen, Bus bus, BYTE protocol, BYTE eventType); + + inline int Init(); + inline BYTE ReadByte(BYTE*& pBuffer); + inline unsigned short ReadUInt16(BYTE*& pBuffer); + inline unsigned long ReadUInt32(BYTE*& pBuffer); + inline unsigned long long ReadUInt64(BYTE*& pBuffer); +private: + AbiIpcDevice* m_abiDevice; + + IABIListener* m_pAbiListener; + bool m_bStarted; + bool m_bSpyMode; + void* m_objectMap[MAX_CONTEXT_OBJECT]; + + CEvent m_requestEvent; + CLock m_lock; + + BYTE m_errorCode; + BYTE* m_pResult; + int m_nResultLength; + + CABIFilter m_filter; + + DWORD m_dwUniqueId; +}; diff --git a/K2LABI/ABI/ABICommands.cpp b/K2LABI/ABI/ABICommands.cpp new file mode 100644 index 0000000..1fe2f4f --- /dev/null +++ b/K2LABI/ABI/ABICommands.cpp @@ -0,0 +1,1426 @@ +#include <string.h> +#include "ABICommands.h" +#include "ResultParser.h" +#include "ABIFunctionDefinition.h" + +using namespace K2L::Automotive::ABI; + +int CABICommands::GetSupportedFeatures(IABI* pAbi, char*& result) +{ + return GetInformation(pAbi, SupportedFeatures, result); +} + +int CABICommands::AddReceiverEx(IABI* pAbi, unsigned short handle, Bus bus, unsigned int param1, unsigned int param2) +{ + switch (bus) + { + case CAN1: + case CAN2: + case CAN3: + case CAN4: + case CAN5: + case CAN6: + case XCAN1: + case XCAN2: + case XCAN3: + case XCAN4: + case XCAN5: + case XCAN6: + if (param1 > param2) + { + unsigned int temp = param1; + param1 = param2; + param2 = temp; + } + pAbi->AddIdIntervalFilter(bus, handle, param1, param2); + break; + case LIN1: + case LIN2: + case LIN3: + case LIN4: + case LINTP1: + case LINTP2: + case LINTP3: + case LINTP4: + if (param1 == 0xFF) + { + pAbi->AddMaskedIdFilter(bus, handle, param1, 0); + } + else + { + pAbi->AddMaskedIdFilter(bus, handle, param1, 0xFFFFFFFF); + } + param2 = 0; + break; + default: + pAbi->AddMaskedIdFilter(bus, handle, param2, param1); + break; + + } + return CABICommands::AddReceiver(pAbi, handle, bus, param1, param2); +} + +int CABICommands::RemoveReceiverEx(IABI* pAbi, unsigned short handle) +{ + pAbi->RemoveFilter(handle); + return CABICommands::Delete(pAbi, handle); +} + +int CABICommands::SendMostHighMessage(IABI* pAbi, unsigned short handle, unsigned short targetAddress, BYTE fblockID, BYTE instanceID, unsigned short functionID, BYTE opType, unsigned short payloadLength, BYTE* payload) +{ + unsigned int messageId = fblockID << 24; + messageId |= instanceID << 16; + messageId |= (functionID & 0xFFFu) << 4; + messageId |= opType & 0x0Fu; + return SendMessage(pAbi, handle, MOST_ASYNC1_HIGH, targetAddress, messageId, payloadLength, payload); +} + +int CABICommands::SendMostADSMessage(IABI* pAbi, unsigned short handle, unsigned short targetAddress, unsigned short payloadLength, BYTE* payload) +{ + return SendMessage(pAbi, handle, MOST_ASYNC1_RAW, targetAddress, 0, payloadLength, payload); +} + +int CABICommands::SendMostAMSMessage(IABI* pAbi, unsigned short handle, unsigned short targetAddress, BYTE fblockID, BYTE instanceID, unsigned short functionID, BYTE opType, unsigned short payloadLength, BYTE* payload) +{ + unsigned int messageId = fblockID << 24; + messageId |= instanceID << 16; + messageId |= (functionID & 0xFFFu) << 4; + messageId |= opType & 0x0Fu; + return SendMessage(pAbi, handle, MOST_CONTROL1_AMS, targetAddress, messageId, payloadLength, payload); +} + +int CABICommands::SendMostCMSMessage(IABI* pAbi, unsigned short handle, unsigned short targetAddress, BYTE fblockID, BYTE instanceID, unsigned short functionID, BYTE opType, unsigned short payloadLength, BYTE* payload) +{ + unsigned int messageId = fblockID << 24; + messageId |= instanceID << 16; + messageId |= (functionID & 0xFFFu) << 4; + messageId |= opType & 0x0Fu; + return SendMessage(pAbi, handle, MOST_CONTROL1_RAW, targetAddress, messageId, payloadLength, payload); +} + +//int CABICommands::SendCmsMessage(IABI* pAbi, unsigned short handle, unsigned short targetAddress, BYTE fblockId, BYTE instanceId, unsigned short functionId, BYTE opType, BYTE telId, BYTE telLen, bool isMost150, BYTE frameCount, bool isSegmented, unsigned short payloadLength, BYTE* payload) +//{ +// if (!pAbi) { return 0; } +// +// int resultLen = 0; +// BYTE error = 0; +// +// unsigned int messageId = fblockId << 24; +// messageId |= instanceId << 16; +// messageId |= (functionId & 0xFFFu) << 4; +// messageId |= opType & 0x0Fu; +// +// int i = 0; +// int parameterCnt = 6; +// +// payloadLength += isMost150 ? 2 : 1; +// payloadLength += isSegmented ? 1 : 0; +// BYTE bus = MOST_CONTROL1_RAW; +// +// ParamDef* pParams = NULL; +// ParamDef params[9]; +// +// params[0].m_pData = &handle; +// params[0].m_nLength = 2; +// params[1].m_pData = &bus; +// params[1].m_nLength = 1; +// params[2].m_pData = &targetAddress; +// params[2].m_nLength = 2; +// params[3].m_pData = &messageId; +// params[3].m_nLength = 4; +// params[4].m_pData = &payloadLength; +// params[4].m_nLength = 2; +// +// if(isMost150) +// { +// BYTE highTel = (BYTE) ((telId << 4) | ((telLen >> 8) & 0xF)); +// BYTE lowTel = (BYTE) (telLen & 0xFF); +// +// params[5].m_pData = &highTel; +// params[5].m_nLength = 1; +// params[6].m_pData = &lowTel; +// params[6].m_nLength = 1; +// } +// else +// { +// BYTE tel = (BYTE)((telId << 4) | (telLen & 0xF)); +// +// params[5].m_pData = &tel; +// params[5].m_nLength = 1; +// params[6].m_pData = 0; +// params[6].m_nLength = 0; +// } +// if(isSegmented) +// { +// params[7].m_pData = &frameCount; +// params[7].m_nLength = 1; +// } +// else +// { +// params[7].m_pData = 0; +// params[7].m_nLength = 0; +// } +// +// params[8].m_pData = payload; +// params[8].m_nLength = payloadLength; +// +// pParams = params; +// +// int bufferLength = 0; +// BYTE* pBuffer = CResultParser::ToByteArray(pParams, 6, bufferLength); +// +// BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__SendMessage, pBuffer, bufferLength, resultLen, error); +// delete pBuffer; +// +// if (!pRes){ return -1; } +// +// return error; +//} + +int CABICommands::SendCANMessage(IABI* pAbi, unsigned short handle, BYTE channelNumber, unsigned short id, unsigned short payloadLength, BYTE* payload) +{ + Bus canChannel = CAN1; + switch (channelNumber) + { + case 1: + canChannel = CAN1; + break; + case 2: + canChannel = CAN2; + break; + case 3: + canChannel = CAN3; + break; + case 4: + canChannel = CAN4; + break; + case 5: + canChannel = CAN5; + break; + case 6: + canChannel = CAN6; + break; + default: + return tmRetValBadBusId; + } + + return SendMessage(pAbi, handle, canChannel, 0, id, payloadLength, payload); +} + +int CABICommands::SendXCANMessage(IABI* pAbi, unsigned short handle, BYTE channelNumber, unsigned int id, unsigned short payloadLength, BYTE* payload) +{ + Bus canChannel = XCAN1; + switch (channelNumber) + { + case 1: + canChannel = XCAN1; + break; + case 2: + canChannel = XCAN2; + break; + case 3: + canChannel = XCAN3; + break; + case 4: + canChannel = XCAN4; + break; + case 5: + canChannel = XCAN5; + break; + case 6: + canChannel = XCAN6; + break; + default: + return tmRetValBadBusId; + } + + return SendMessage(pAbi, handle, canChannel, 0, id, payloadLength, payload); +} + +int CABICommands::SendLINMessage(IABI* pAbi, unsigned short handle, BYTE channelNumber, BYTE id, unsigned short payloadLength, BYTE* payload) +{ + Bus linChannel = LIN1; + switch (channelNumber) + { + case 1: + linChannel = LIN1; + break; + case 2: + linChannel = LIN2; + break; + case 3: + linChannel = LIN3; + break; + case 4: + linChannel = LIN4; + break; + default: + return tmRetValBadBusId; + } + + return SendMessage(pAbi, handle, linChannel, 0, id, payloadLength, payload); +} +int CABICommands::SendLINTpMessage(IABI* pAbi, unsigned short handle, BYTE channelNumber, BYTE frameId, BYTE nodeAddress, BYTE serviceId, unsigned short payloadLength, BYTE* payload) +{ + Bus linChannel = LINTP1; + switch (channelNumber) + { + case 1: + linChannel = LINTP1; + break; + case 2: + linChannel = LINTP2; + break; + case 3: + linChannel = LINTP3; + break; + case 4: + linChannel = LINTP4; + break; + default: + return tmRetValBadBusId; + } + + unsigned int messageId = frameId; + messageId += (unsigned int)nodeAddress << 8; + messageId += (unsigned int)serviceId << 16; + + return SendMessage(pAbi, handle, linChannel, 0, messageId, payloadLength, payload); +} + +int CABICommands::SendFRMessage(IABI* pAbi, unsigned short handle, FrChannel frChannel, BYTE cycleOffset, BYTE cycleRepetition, unsigned short frameID, unsigned short payloadLength, BYTE* payload) +{ + unsigned int messageId = frameID; + messageId |= cycleOffset << 16; + if(0 < cycleRepetition) + { + messageId |= (cycleRepetition - 1) << 24; + } + + switch(frChannel) + { + case A: + messageId |= (1 << 12); + break; + case B: + messageId |= (2 << 12); + break; + case AB: + messageId |= (3 << 12); + break; + default: + break; + } + + return SendMessage(pAbi, handle, FLEXRAY1, 0, messageId, payloadLength, payload); +} + +int CABICommands::ReadBusConfiguration(IABI* pAbi, Bus bus, BYTE*& configuration, WORD& length) +{ + if (pAbi == NULL) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__ReadBusConfiguration, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + configuration = new BYTE[resultLen]; + memcpy(configuration, pRes, resultLen); + length = resultLen; + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::GetAllUsedHandles(IABI* pAbi, BYTE*& handles, WORD& length) +{ + if (pAbi == NULL) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__GetAllUsedHandles, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + handles = new BYTE[resultLen]; + memcpy(handles, pRes, resultLen); + length = resultLen; + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::GetInformationOfObject( IABI* pAbi, WORD handle, ObjectType& type, bool& isStarted, BYTE& groupId, Bus& bus) +{ + if (pAbi == NULL) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__GetInformationOfObject, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes || ((resultLen < 4) && (error != 0))) + { + type = NullObject; + isStarted = false; + groupId = 0; + bus = UnknownBusId; + pAbi->EndRequest(); + return -1; + } + + type = (ObjectType) pRes[0]; + isStarted = pRes[1] > 0 ? true : false; + groupId = pRes[2]; + bus = (Bus) pRes[3]; + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::GetSupportedCanSpeeds( IABI* pAbi, Bus bus, CanTransceiver type, CanSpeed*& speeds, WORD& length) +{ + if (pAbi == NULL) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + params[1].m_pData = &type; + params[1].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__GetSupportedCanSpeeds, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + BYTE tmpLength = pRes[0]; + speeds = new CanSpeed[tmpLength]; + + for (int i = 0; i < tmpLength; i++) + { + speeds[i] = (CanSpeed) pRes[i + 1]; + } + + length = tmpLength; + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::GetSupportedCanTransceivers( IABI* pAbi, Bus bus, CanTransceiver*& types, WORD& length) +{ + if (pAbi == NULL) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__GetSupportedCanTransceivers, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + BYTE tmpLength = pRes[0]; + types = new CanTransceiver[tmpLength]; + + for (int i = 0; i < tmpLength; i++) + { + types[i] = (CanTransceiver) pRes[i + 1]; + } + + length = tmpLength; + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::GetMostAllocationTable( IABI* pAbi, WORD& length, AllocationTableEntry*& allocationTable) +{ + if (pAbi == NULL) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetMostAllocationTable, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + length = *(unsigned short*)pRes; + allocationTable = NULL; + if(length > 0) + { + allocationTable = new AllocationTableEntry[length]; + + for (int i = 0; i < length; i++) + { + allocationTable[i].connectionLabel = *(WORD*) (pRes + 2 + i * 4); + allocationTable[i].channelWidth = *(WORD*) (pRes + 2 + i * 4 + 2); + } + } + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::SendEchoCommand( IABI* pAbi, WORD requestLength, BYTE* request, WORD& answerLength, BYTE*& answer) +{ + if (!pAbi) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &requestLength; + params[0].m_nLength = 2; + params[1].m_pData = request; + params[1].m_nLength = requestLength; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__SendEchoCommand, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + answerLength = *(WORD*) pRes; + + answer = new BYTE[answerLength]; + memcpy(answer, pRes + 2, answerLength); + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::GetMostAudioTxLabels( IABI* pAbi, WORD& length, LabelEntry*& labels) +{ + if (pAbi == NULL) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetMostAudioTxLabels, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + length = resultLen / 4; + labels = NULL; + if(length > 0) + { + labels = new LabelEntry[length]; + + for (int i = 0; i < length; i++) + { + labels[i] = *(LabelEntry*) (pRes + i * 4); + labels[i].connectionLabel = *(WORD*) (pRes + i * 4); + labels[i].connectorType = (AudioConnectorType) *(pRes + i * 4 + 2); + labels[i].dummy = 0u; + } + } + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::GetMostAudioRxLabels( IABI* pAbi, WORD& length, LabelEntry*& labels) +{ + if (pAbi == NULL) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetMostAudioRxLabels, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + length = resultLen / 4; + labels = NULL; + if(length > 0) + { + labels = new LabelEntry[length]; + + for (int i = 0; i < length; i++) + { + labels[i] = *(LabelEntry*) (pRes + i * 4); + labels[i].connectionLabel = *(WORD*) (pRes + i * 4); + labels[i].connectorType = (AudioConnectorType) *(pRes + i * 4 + 2); + labels[i].dummy = 0u; + } + } + + pAbi->EndRequest(); + + return error; +} + +void CABICommands::ReleaseBuffer(LabelEntry** ptr) +{ + if(NULL != *ptr) + { + delete[] *ptr; + *ptr = NULL; + } +} + +void CABICommands::ReleaseBuffer(char** ptr) +{ + if(NULL != *ptr) + { + delete[] *ptr; + *ptr = NULL; + } +} + +void CABICommands::ReleaseBuffer(BYTE** ptr) +{ + if(NULL != *ptr) + { + delete[] *ptr; + *ptr = NULL; + } +} + +void CABICommands::ReleaseBuffer(AllocationTableEntry** ptr) +{ + if(NULL != *ptr) + { + delete[] *ptr; + *ptr = NULL; + } +} + +void CABICommands::ReleaseBuffer(CanSpeed** ptr) +{ + if(NULL != *ptr) + { + delete[] *ptr; + *ptr = NULL; + } +} + +void CABICommands::ReleaseBuffer(CanTransceiver** ptr) +{ + if(NULL != *ptr) + { + delete[] *ptr; + *ptr = NULL; + } +} + +void CABICommands::ReleaseBuffer(AudioConnectionType** ptr) +{ + if(NULL != *ptr) + { + delete[] *ptr; + *ptr = NULL; + } +} + +int CABICommands::MostAudioRxConnectSync(IABI* pAbi, AudioBandwidth bandwidth, unsigned int label, bool isSwitchForced, WORD& errorCode) +{ + if (!pAbi) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[3]; + params[0].m_pData = &bandwidth; + params[0].m_nLength = 1; + params[1].m_pData = &label; + params[1].m_nLength = 4; + params[2].m_pData = &isSwitchForced; + params[2].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 3, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__MostAudioRxConnectSync, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + unsigned int value = *(unsigned int*)pRes; + + if(error == tmRetErrorDuringExecution) + { + errorCode = (unsigned short) value; + } + else + { + errorCode = 0u; + } + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::MostAudioRxDisconnectSync(IABI* pAbi, unsigned int label, WORD& errorCode) +{ + if (!pAbi) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &label; + params[0].m_nLength = 4; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__MostAudioRxDisconnectSync, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + unsigned int value = *(unsigned int*)pRes; + + if(error == tmRetErrorDuringExecution) + { + errorCode = (unsigned short) value; + } + else + { + errorCode = 0u; + } + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::MostAudioTxAllocateConnectSync(IABI* pAbi, AudioBandwidth bandwidth, unsigned int& connectionLabel, WORD& errorCode) +{ + if (!pAbi) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bandwidth; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__MostAudioTxAllocateConnectSync, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + unsigned int value = *(unsigned int*)pRes; + + if(error == tmRetErrorDuringExecution) + { + connectionLabel = 0u; + errorCode = (unsigned short) value; + } + else + { + connectionLabel = value; + errorCode = 0u; + } + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::MostAudioTxAllocateConnectSync(IABI* pAbi, AudioBandwidth bandwidth, AudioConnectorType connector, unsigned int& connectionLabel, WORD& errorCode) +{ + if (!pAbi) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &bandwidth; + params[0].m_nLength = 1; + params[1].m_pData = &connector; + params[1].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__MostAudioTxAllocateConnectSync, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + unsigned int value = *(unsigned int*)pRes; + + if(error == tmRetErrorDuringExecution) + { + connectionLabel = 0u; + errorCode = (unsigned short) value; + } + else + { + connectionLabel = value; + errorCode = 0u; + } + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::MostAudioTxDisconnectSync(IABI* pAbi, unsigned int label, WORD& errorCode) +{ + if (!pAbi) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &label; + params[0].m_nLength = 4; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__MostAudioTxDisconnectSync, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + unsigned int value = *(unsigned int*)pRes; + + if(error == tmRetErrorDuringExecution) + { + errorCode = (unsigned short) value; + } + else + { + errorCode = 0u; + } + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::GetExtendedBaudrate(IABI* pAbi, Bus busId + , unsigned int& prescaler, unsigned int& tseg1, unsigned int& tseg2, unsigned int& sjw) +{ + if (!pAbi) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &busId; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetExtendedBaudrate, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + prescaler = 0; + tseg1 = 0; + tseg2 = 0; + sjw = 0; + pAbi->EndRequest(); + return -1; + } + + prescaler = *(unsigned int*) (pRes); + tseg1 = *(unsigned int*) (pRes + 4); + tseg2 = *(unsigned int*) (pRes + 8); + sjw = *(unsigned int*) (pRes + 12); + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::GetHardwareRevision(IABI* pAbi, BYTE& hwType, BYTE& major, BYTE& minor, BYTE& bugfix) +{ + if (!pAbi) { return 0; } + + int resultLen = 0; + BYTE error = 0; + ParamDef* pParams = NULL; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetHardwareRevision, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + hwType = 0; + major = 0; + minor = 0; + bugfix = 0; + pAbi->EndRequest(); + return -1; + } + + hwType = pRes[0]; + major = pRes[1]; + minor = pRes[2]; + bugfix = pRes[3]; + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::MostSpyEnabled(IABI* pAbi, bool& status, bool& control, bool& async, bool& sync) +{ + if (!pAbi) { return 0; } + + int resultLen = 0; + BYTE error = 0; + ParamDef* pParams = NULL; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__MostSpyEnabled, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + status = false; + control = false; + async = false; + sync = false; + pAbi->EndRequest(); + return -1; + } + + status = pRes[0] > 0 ? true : false; + control = pRes[1] > 0 ? true : false; + async = pRes[2] > 0 ? true : false; + sync = pRes[3] > 0 ? true : false; + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::GetCanTpRxConfig(IABI* pAbi, BYTE& blockSize, BYTE& separationTime, WORD& consecutiveFrameTimeout) +{ + if (!pAbi) { return 0; } + + int resultLen = 0; + BYTE error = 0; + ParamDef* pParams = NULL; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__GetCanTpRxConfig, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + blockSize = 0; + separationTime = 0; + consecutiveFrameTimeout = 0; + pAbi->EndRequest(); + return -1; + } + + blockSize = pRes[0]; + separationTime = pRes[1]; + consecutiveFrameTimeout = *(unsigned short*) (pRes + 2); + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::GetCanTpTxConfig(IABI* pAbi, WORD& flowControlTimeout, WORD& clearToSendTimeout) +{ + if (!pAbi) { return 0; } + + int resultLen = 0; + BYTE error = 0; + ParamDef* pParams = NULL; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__GetCanTpTxConfig, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + flowControlTimeout = 0; + clearToSendTimeout = 0; + pAbi->EndRequest(); + return -1; + } + + flowControlTimeout = *(unsigned short*) (pRes); + clearToSendTimeout = *(unsigned short*) (pRes + 2); + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::GetCanTpPattern(IABI* pAbi, BYTE& pattern) +{ + if (!pAbi) { return 0; } + + int resultLen = 0; + BYTE error = 0; + ParamDef* pParams = NULL; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__GetCanTpPattern, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pattern = 0; + pAbi->EndRequest(); + return -1; + } + + pattern = pRes[0]; + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::GetMostAudioSupportedTxConnectors(IABI* pAbi, WORD& length, AudioConnectorType*& types) +{ + if (pAbi == NULL) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetMostAudioSupportedTxConnectors, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + length = *(unsigned short*) (pRes); + types = NULL; + if(length > 0) + { + types = new AudioConnectorType[length]; + + for (int i = 0; i < length; i++) + { + types[i] = (AudioConnectorType) *(pRes + i + 2); + } + } + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::StressNicFunctionGet(IABI* pAbi, BYTE fblockId, unsigned short functionId, WORD& length, BYTE*& payload) +{ + if (pAbi == NULL) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &fblockId; + params[0].m_nLength = 1; + params[1].m_pData = &functionId; + params[1].m_nLength = 2; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)StressNic, (BYTE)FunId__StressNicFunctionGet, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + length = *(WORD*) pRes; + + payload = new BYTE[length]; + memcpy(payload, pRes + 2, length); + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::StressNicFunctionGetExtended(IABI* pAbi, BYTE fblockId, unsigned short functionId, WORD requestLength, BYTE* request, WORD& responseLength, BYTE*& response) +{ + if (pAbi == NULL) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[4]; + params[0].m_pData = &fblockId; + params[0].m_nLength = 1; + params[1].m_pData = &functionId; + params[1].m_nLength = 2; + params[2].m_pData = &requestLength; + params[2].m_nLength = 2; + params[3].m_pData = request; + params[3].m_nLength = requestLength; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 4, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)StressNic, (BYTE)FunId__StressNicFunctionGetExtended, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + responseLength = *(WORD*) pRes; + + response = new BYTE[responseLength]; + memcpy(response, pRes + 2, responseLength); + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::GetVolume(IABI* pAbi, AudioConnectorType connector, bool isInput, int& volumeLeft, int& volumeRight) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &connector; + params[0].m_nLength = 1; + params[1].m_pData = &isInput; + params[1].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetVolume, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + volumeLeft = 0; + volumeRight = 0; + pAbi->EndRequest(); + return -1; + } + + volumeLeft = *(int*) pRes; + volumeRight = *(int*) (pRes + 4); + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::GetSupportedVolumeRange(IABI* pAbi, AudioConnectorType connector, bool isInput, int& minVolume, int& maxVolume) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &connector; + params[0].m_nLength = 1; + params[1].m_pData = &isInput; + params[1].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetSupportedVolumeRange, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + minVolume = 0; + maxVolume = 0; + pAbi->EndRequest(); + return -1; + } + + minVolume = *(int*) pRes; + maxVolume = *(int*) (pRes + 4); + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::SendAbsoluteTriggerSequence(IABI* pAbi, WORD length, AbsoluteTriggerCommand* sequence) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + if(length == 0) + return 0; + + ParamDef* pParams = new ParamDef[length * 2]; + for(int i = 0; i < length; i++) + { + pParams[i * 2].m_pData = &sequence[i].isActive; + pParams[i * 2].m_nLength = 1; + pParams[i * 2 + 1].m_pData = &sequence[i].timeStamp; + pParams[i * 2 + 1].m_nLength = 8; + } + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, length * 2, bufferLength); + delete[] pParams; + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__SendAbsoluteTriggerSequence, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommands::SendRelativeTriggerSequence(IABI* pAbi, WORD length, RelativeTriggerCommand* sequence) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + if(length == 0) + return 0; + + ParamDef* pParams = new ParamDef[length * 2]; + for(int i = 0; i < length; i++) + { + pParams[i * 2].m_pData = &sequence[i].isActive; + pParams[i * 2].m_nLength = 1; + pParams[i * 2 + 1].m_pData = &sequence[i].delay; + pParams[i * 2 + 1].m_nLength = 2; + } + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, length * 2, bufferLength); + delete[] pParams; + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__SendRelativeTriggerSequence, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +}
\ No newline at end of file diff --git a/K2LABI/ABI/ABICommands.h b/K2LABI/ABI/ABICommands.h new file mode 100644 index 0000000..1933bbc --- /dev/null +++ b/K2LABI/ABI/ABICommands.h @@ -0,0 +1,563 @@ +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// K2L GmbH +/// +/// \file +/// This file contains the api of all abi commands. +/// +/// \ingroup ABICommands +/// +/// \par COPYRIGHT (c) 2000-2010 by K2L GmbH +/// All rights reserved. +/// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// Alle Rechte an der Software verbleiben bei der K2L GmbH. +/// +/// Die K2L GmbH raeumt dem Lizenznehmer nach vollstaendiger +/// Bezahlung der Lizenzgebuehr ein nicht ausschliessliches, +/// unwiderrufliches, nicht uebertragbares, zeitlich und geografisch +/// nicht beschraenktes Recht zur Nutzung der jeweils +/// auftragsgegenstaendlichen Software innerhalb des Lizenznehmers ein. +/// +/// Die Weitergabe des Nutzungsrechts durch den Lizenznehmer ist auf +/// dessen Zulieferer beschraenkt. Die Zulieferer sind zu verpflichten, +/// die Software nur im Rahmen von Projekten fuer den Lizenznehmer +/// zu verwenden; weitere Rechte der Zulieferer sind auszuschliessen. +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//@{ +#pragma once + +#include "ABICommandsEx.h" + +namespace K2L +{ + namespace Automotive + { + namespace ABI + { + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// \defgroup OBJ Object control +/// \ingroup ABICommands +/// This group combines all commands needed to manipulate Sender or Receiver Objects in the device. +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// \defgroup HW Hardware Access +/// \ingroup ABICommands +/// This group combines all commands which belongs directly to the hardware. +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// \defgroup MOST MOST +/// \ingroup ABICommands +/// This group combines all commands which belongs to the MOST bus of the ABI device. +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// \defgroup CAN CAN +/// \ingroup ABICommands +/// This group combines all commands which belongs to the CAN bus of the ABI device. +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// \defgroup CANTP CAN Transport Protocol +/// \ingroup ABICommands +/// This group combines all commands which belongs to the CAN transport protocol, which is located on top of the CAN protocol. +/// Therefor make sure the CAN bus is already started with the commands in CAN. +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// \defgroup FR FlexRay +/// \ingroup ABICommands +/// This group combines all commands which belongs to the FlexRay bus of the ABI device. +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// \defgroup LIN LIN +/// \ingroup ABICommands +/// This group combines all commands which belongs to the LIN bus of the ABI device. +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// \defgroup EXT ABI Extended Commands +/// \ingroup ABICommands +/// This group provides a generic way to set or get properties to the device. Like a hashtable, the key / value pair is a String. +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// \defgroup ABICommands ABI Commands +/// This class is responsible for all the communication between the PC and the device. For better handling the commands of this class are grouped by their functionality. +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// \brief This class is responsible for all the communication between the PC and the device. For better handling the commands of this class are grouped by their functionality. +/// \ingroup ABICommands +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +class K2LABI_API CABICommands : public CABICommandsEx +{ +public: + /// Adds a receiving rule into the current group. Only the added messages will be reported to the PC. + /// \param[in] abi Used IABI instance. + /// \param[in] handle Handle of the receiving rule. + /// \param[in] bus Receiving bus. + /// \param[in] param1 Parameter 1. + /// \param[in] param2 Parameter 2. + /// \note MOST: param1: mask (0 means all ids; 0xFFFFFFFF means this id). param2: message identifier value. + /// \note MOST ADS: param1 and param2 are not used. It is only a receiver required. + /// \note FlexRay: param1: mask (0 means all ids; 0xFFFFFFFF means this id). param2: message identifier value. + /// \note CAN: param1: minimal message identifier. param2: maximal identifier. + /// \note LIN: param1: message identifier (0xFF means all ids). param2: Not used. + /// \note LINTP: param1: Node address (0xFF means all NADs). param2: Not used. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int AddReceiverEx(IABI* pAbi, unsigned short handle, Bus bus, unsigned int param1, unsigned int param2); + + /// Removes a receiving rule from the current group. + /// \param[in] abi"> Used IABI instance. + /// \param[in] handle"> Handle of the receiving rule. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int RemoveReceiverEx(IABI* pAbi, unsigned short handle); + + /// Sends a message immediately to MOST asynchronous channel with MOST HIGH protocol. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of tx message. + /// \param[in] targetAddress Target address. + /// \param[in] fblockID The Function Block identifier. + /// \param[in] instanceID The Function Block instance number. + /// \param[in] functionID The function identifier of the FBlock. + /// \param[in] opType The Function Block operation type identifier. + /// \param[in] payloadLength Length of payload. + /// \param[in] payload Payload data. + /// \note The maximum length of message is 65535 bytes. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int SendMostHighMessage(IABI* pAbi, unsigned short handle, unsigned short targetAddress, BYTE fblockID, BYTE instanceID, unsigned short functionID, BYTE opType, unsigned short payloadLength, BYTE* payload); + + /// Sends a message immediately to MOST asynchronous channel with ADS protocol. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of tx message. + /// \param[in] targetAddress Target address. + /// \param[in] payloadLength Length of payload. + /// \param[in] payload Payload data. + /// \note The maximum length of message is 1014 bytes. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int SendMostADSMessage(IABI* pAbi, unsigned short handle, unsigned short targetAddress, unsigned short payloadLength, BYTE* payload); + + /// Sends a message immediately to MOST control channel with AMS protocol. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of tx message. + /// \param[in] targetAddress Target address. + /// \param[in] fblockID The Function Block identifier. + /// \param[in] instanceID The Function Block instance number. + /// \param[in] functionID The function identifier of the FBlock. + /// \param[in] opType The Function Block operation type identifier. + /// \param[in] payloadLength Length of payload. + /// \param[in] payload Payload data. + /// \note The maximum length of message is 4096 bytes. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int SendMostAMSMessage(IABI* pAbi, unsigned short handle, unsigned short targetAddress, BYTE fblockID, BYTE instanceID, unsigned short functionID, BYTE opType, unsigned short payloadLength, BYTE* payload); + + /// Sends a message immediately to MOST control channel with CMS protocol. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of tx message. + /// \param[in] targetAddress Target address. + /// \param[in] fblockID The Function Block identifier. + /// \param[in] instanceID The Function Block instance number. + /// \param[in] functionID The function identifier of the FBlock. + /// \param[in] opType The Function Block operation type identifier. + /// \param[in] payloadLength Length of payload. + /// \param[in] payload The first byte (MOST25/50) / The first 2 bytes (MOST150) have to be the TelId and TelLen. Afterwards following the payload of the message. + /// \note The maximum size of payload (all after TelLen) is 12 bytes (MOST25/50) or 45 bytes (MOST150). + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int SendMostCMSMessage(IABI* pAbi, unsigned short handle, unsigned short targetAddress, BYTE fblockID, BYTE instanceID, unsigned short functionID, BYTE opType, unsigned short payloadLength, BYTE* payload); + + /// Sends a message immediately to MOST control channel with CMS protocol. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of tx message. + /// \param[in] targetAddress Target address. + /// \param[in] fblockId The Function Block identifier. + /// \param[in] instanceId The Function Block instance number. + /// \param[in] functionId The function identifier of the FBlock. + /// \param[in] opType The Function Block operation type identifier. + /// \param[in] telId The telegram identifier. + /// \param[in] telLen The telegram length (including the frame count). + /// \param[in] isMost150 true if MOST 150 is used (Telegram information is 2 bytes long). + /// \param[in] frameCount The frame count. + /// \param[in] isSegmented true if its a message segment. If set to false frameCount is ignored. + /// \param[in] payloadLength Length of payload. + /// \param[in] payload The payload of the message. + /// \note The maximum size of payload (all after TelLen) is 12 bytes (MOST25/50) or 45 bytes (MOST150). + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + //static int SendCmsMessage(IABI* pAbi, unsigned short handle, unsigned short targetAddress, BYTE fblockId, BYTE instanceId, unsigned short functionId, BYTE opType, BYTE telId, BYTE telLen, bool isMost150, BYTE frameCount, bool isSegmented, unsigned short payloadLength, BYTE* payload); + + /// Sends a message immediately to CAN. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of tx message. + /// \param[in] channelNumber Selected CAN channel number. + /// \param[in] id Object identifier (11 bit). + /// \param[in] payloadLength Length of payload. + /// \param[in] payload Payload data. + /// \note The maximum length of message is 8 bytes. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup CAN + static int SendCANMessage(IABI* pAbi, unsigned short handle, BYTE channelNumber, unsigned short id, unsigned short payloadLength, BYTE* payload); + + /// Sends a message immediately to CAN with extended identifiers. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of tx message. + /// \param[in] channelNumber Selected CAN channel number. + /// \param[in] id Object identifier (29 bit). + /// \param[in] payloadLength Length of payload. + /// \param[in] payload Payload data. + /// \note The maximum length of message is 8 bytes. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup CAN + static int SendXCANMessage(IABI* pAbi, unsigned short handle, BYTE channelNumber, unsigned int id, unsigned short payloadLength, BYTE* payload); + + /// Sends a message immediately to LIN. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of tx message. + /// \param[in] channelNumber Selected LIN channel number. + /// \param[in] id Object identifier. + /// \param[in] payloadLength Length of payload. + /// \param[in] payload Payload data. + /// \note The maximum length of message is 8 bytes. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup LIN + static int SendLINMessage(IABI* pAbi, unsigned short handle, BYTE channelNumber, BYTE id, unsigned short payloadLength, BYTE* payload); + + /// Sends a message immediately to LIN TP. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of tx message. + /// \param[in] channelNumber Selected LIN channel number. + /// \param[in] frameId Identifier of message. Request is 60 and response is 61. + /// \param[in] nodeAddress Address of the target node. + /// \param[in] serviceId Identifier of the service. + /// \param[in] payloadLength Length of payload. + /// \param[in] payload Payload data. + /// \note The maximum length of message is 4095 bytes. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup LIN + static int SendLINTpMessage(IABI* pAbi, unsigned short handle, BYTE channelNumber, BYTE frameId, BYTE nodeAddress, BYTE serviceId, unsigned short payloadLength, BYTE* payload); + + /// Sends a message immediately to FlexRay. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of tx message. + /// \param[in] frChannel Channel identifier. + /// \param[in] cycleOffset Offset of cycle. + /// \param[in] cycleRepetition Repetition of cycle. + /// \param[in] frameID Frame identifier. + /// \param[in] payloadLength Length of payload. + /// \param[in] payload Payload data. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup FR + static int SendFRMessage(IABI* pAbi, unsigned short handle, FrChannel frChannel, BYTE cycleOffset, BYTE cycleRepetition, unsigned short frameID, unsigned short payloadLength, BYTE* payload); + + /// Reads out the startup configuration stored in the EEPROM for the selected bus. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus The bus, which configuration should be read out. + /// \param[out] configuration Blob containing the startup configuration. + /// \param[out] length Length of the configuration blob. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int ReadBusConfiguration(IABI* pAbi, Bus bus, BYTE*& configuration, WORD& length); + + /// Gets all used object handles. + /// \param[in] pAbi Used IABI instance. + /// \param[out] handles All used object handles. Each handle consists of two bytes (low|high). + /// \param[out] length Length of list. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int GetAllUsedHandles(IABI* pAbi, BYTE*& handles, WORD& length); + + /// Gets information of an object. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle The handle that should be read out. + /// \param[out] type Type of object. + /// \param[out] isStarted If set to true then is started. + /// \param[out] groupId The group id of the object. + /// \param[out] bus The bus id of the object. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int GetInformationOfObject( IABI* pAbi, WORD handle, ObjectType& type, bool& isStarted, BYTE& groupId, Bus& bus); + + /// Gets all supported can speed of this channel/transceiver combination. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus The bus that should be read out. + /// \param[in] type The type that should be read out. + /// \param[out] speeds List of all supported speeds of this channel/transceiver combination. + /// \param[out] length Length of list. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup CAN + static int GetSupportedCanSpeeds( IABI* pAbi, Bus bus, CanTransceiver type, CanSpeed*& speeds, WORD& length); + + /// Gets all supported can transceivers of a CAN channel. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus The bus that should be read out. + /// \param[out] types List of all supported can transceivers of a CAN channel. + /// \param[out] length Length of list. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup CAN + static int GetSupportedCanTransceivers( IABI* pAbi, Bus bus, CanTransceiver*& types, WORD& length); + + /// Gets the most allocation table from the SPYNIC. + /// \param[in] pAbi Used IABI instance. + /// \param[out] length Length of arrays connectionLabels and channelWidths. + /// \param[out] connectionLabels List of connection labels. + /// \param[out] channelWidths List of channel widths. Each entry in list are coppeled to the same position in connectionLabels. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \remarks Only available for MOST50. + /// \ingroup MOST + static int GetMostAllocationTable( IABI* pAbi, WORD& length, AllocationTableEntry*& allocationTable); + + /// Sends a byte array to the firmware. The firmware will answer with the same array. + /// \param[in] pAbi Used IABI instance. + /// \param[in] requestLength Length of request array. + /// \param[in] request The request byte array. + /// \param[out] answerLength Length of answer array. + /// \param[out] answer The answer byte array. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int SendEchoCommand( IABI* pAbi, WORD requestLength, BYTE* request, WORD& answerLength, BYTE*& answer); + + /// Gets used connection labels on transmission side. + /// \param[in] pAbi Used IABI instance. + /// \param[out] length Length of label array. + /// \param[out] labels List of all used transmission labels on tx side of audio streaming. Length is 0 if no connection label is used. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetMostAudioTxLabels( IABI* pAbi, WORD& length, LabelEntry*& labels); + + /// Gets used connection labels on receive side. + /// \param[in] pAbi Used IABI instance. + /// \param[out] length Length of label array. + /// \param[out] labels List of all used transmission labels on tx side of audio streaming. Length is 0 if no connection label is used. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetMostAudioRxLabels( IABI* pAbi, WORD& length, LabelEntry*& labels); + + /// Frees the memory which was internaly allocated by the ABI library to report a string. + /// \param[in] ptr Pointer to a string returned by the ABI library. (Like GetSupportedFeature, e.g.) + /// \ingroup OBJ + static void ReleaseBuffer(char** ptr); + + /// Frees the memory which was internaly allocated by the ABI library to report a word array. + /// \param[in] ptr Pointer to a word returned by the ABI library. (Like GetMostTxLabels, e.g.) + /// \ingroup OBJ + static void ReleaseBuffer(LabelEntry** ptr); + + /// Frees the memory which was internaly allocated by the ABI library to report a blob. + /// \param[in] ptr Pointer to a byte array returned by the ABI library. (Like ReadBusConfiguration, e.g.) + /// \ingroup OBJ + static void ReleaseBuffer(BYTE** ptr); + + /// Frees the memory which was internaly allocated by the ABI library to report an allocation table. + /// \param[in] ptr Pointer to a AllocationTableEntry array returned by the ABI library. (Like GetMostAllocationTable, e.g.) + /// \ingroup OBJ + static void ReleaseBuffer(AllocationTableEntry** ptr); + + /// Frees the memory which was internaly allocated by the ABI library. + /// \param[in] ptr Pointer to a CanSpeed array returned by the ABI library. (Like GetSupportedCanSpeeds, e.g.) + /// \ingroup OBJ + static void ReleaseBuffer(CanSpeed** ptr); + + /// Frees the memory which was internaly allocated by the ABI library. + /// \param[in] ptr Pointer to a CanTransceiver array returned by the ABI library. (Like GetSupportedCanTransceivers, e.g.) + /// \ingroup OBJ + static void ReleaseBuffer(CanTransceiver** ptr); + + /// Frees the memory which was internaly allocated by the ABI library. + /// \param[in] ptr Pointer to a AudioConnectionType array returned by the ABI library. (Like GetMostAudioSupportedTxConnectors, e.g.) + /// \ingroup OBJ + static void ReleaseBuffer(AudioConnectionType** ptr); + + /// Stream an audio stream from the MOST ring to the SPDIF out connector of the MOCCA compact. If the SPDIF connector is already used for another label it is disconnected and connected to the given label. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bandwidth Desired bandwidth of the audio channel. + /// \param[in] label Label that is used. + /// \param[in] If set to true a switch is forced. Otherwise the function will return an error if the rx connector is currently in use. + /// \param[out] errorCode The error code. This code is only valid if return value is TMErrorCode tmRetErrorDuringExecution. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note This function will first return if the whole command is executed. + /// \ingroup MOST + static int MostAudioRxConnectSync(IABI* pAbi, AudioBandwidth bandwidth, unsigned int label, bool isSwitchForced, WORD& errorCode); + + /// Disconnect the audio streaming from SPDIF out from channel. + /// \param[in] pAbi Used IABI instance. + /// \param[in] label Label that is used. + /// \param[out] errorCode The error code. This code is only valid if return value is TMErrorCode tmRetErrorDuringExecution. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note This function will first return if the whole command is executed. + /// \ingroup MOST + static int MostAudioRxDisconnectSync(IABI* pAbi, unsigned int label, WORD& errorCode); + + /// Allocate a new audio streaming channel and stream the SPDIF in connector of the MOCCA compact to the MOST ring. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bandwidth Desired bandwidth of the allocated audio channel. + /// \param[out] connectionLabel The connection label. The connection label is only valid if return value is tmRetValOk. + /// \param[out] errorCode The error code. This code is only valid if return value is tmRetErrorDuringExecution. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note This function will first return if the whole command is executed. + /// \ingroup MOST + static int MostAudioTxAllocateConnectSync(IABI* pAbi, AudioBandwidth bandwidth, unsigned int& connectionLabel, WORD& errorCode); + + /// Allocate a new audio streaming channel and stream the SPDIF in connector of the MOCCA compact to the MOST ring. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bandwidth Desired bandwidth of the allocated audio channel. + /// \param[in] connector The connector that should be used. + /// \param[out] connectionLabel The connection label. The connection label is only valid if return value is tmRetValOk. + /// \param[out] errorCode The error code. This code is only valid if return value is tmRetErrorDuringExecution. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note This function will first return if the whole command is executed. + /// \ingroup MOST + static int MostAudioTxAllocateConnectSync(IABI* pAbi, AudioBandwidth bandwidth, AudioConnectorType connector, unsigned int& connectionLabel, WORD& errorCode); + + /// Disconnect the audio streaming from SPDIF in from channel. + /// \param[in] pAbi Used IABI instance. + /// \param[in] label Label that is used. + /// \param[out] errorCode The error code. This code is only valid if return value is TMErrorCode tmRetErrorDuringExecution. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note This function will first return if the whole command is executed. + /// \ingroup MOST + static int MostAudioTxDisconnectSync(IABI* pAbi, unsigned int label, WORD& errorCode); + + /// Gets the extended baudrate of a CAN channel. + /// \param[in] pAbi Used IABI instance. + /// \param[in] busId The bus that should be read out. + /// \param[out] prescaler The prescaler parameter. + /// \param[out] tseg1 The phase1 segment parameter. + /// \param[out] tseg2 The phase2 segment parameter. + /// \param[out] sjw The synchronization jump width parameter. + /// \return Status message if operation succeeded. + /// \ingroup CAN + static int GetExtendedBaudrate(IABI* pAbi, Bus busId, unsigned int& prescaler, unsigned int& tseg1, unsigned int& tseg2, unsigned int& sjw); + + /// Gets the hardware revision. + /// \param[in] pAbi Used IABI instance. + /// \param[out] hwType Hardware Type. (0 is undefined, 1 is MOCCA compact) + /// \param[out] major Major version. + /// \param[out] minor Minor version. + /// \param[out] bugfix Bugfix version. + /// \return Status message if operation succeeded. + /// \ingroup HW + static int GetHardwareRevision(IABI* pAbi, BYTE& hwType, BYTE& major, BYTE& minor, BYTE& bugfix); + + /// Get the channels of MOST Spy that are activated. + /// \param[in] pAbi Used IABI instance. + /// \param[out] status Status channel. + /// \param[out] control Control channel. + /// \param[out] async Asynchronous channel. + /// \param[out] sync Synchronous channel. + /// \return Status message if operation succeeded. + /// \ingroup MOST + static int MostSpyEnabled(IABI* pAbi, bool& status, bool& control, bool& async, bool& sync); + + /// Gets the global parameters for CAN TP Rx. + /// \param[in] pAbi Used IABI instance. + /// \param[out] blockSize Flow Control block size. + /// \param[out] separationTime Minimum time gap between the transmission of CF. + /// \param[out] consecutiveFrameTimeout Timeout for the next consecutive frame. + /// \return Status message if operation succeeded. + /// \ingroup CAN + static int GetCanTpRxConfig(IABI* pAbi, BYTE& blockSize, BYTE& separationTime, WORD& consecutiveFrameTimeout); + + /// Gets the global parameters for CAN TP Tx. + /// \param[in] pAbi Used IABI instance. + /// \param[out] flowControlTimeout Timeout interval for flow control. + /// \param[out] clearToSendTimeout Minimum time between two tx messages. + /// \return Status message if operation succeeded. + /// \ingroup CAN + static int GetCanTpTxConfig(IABI* pAbi, WORD& flowControlTimeout, WORD& clearToSendTimeout); + + /// Gets CAN TP pattern to fill CAN telegrams up to 8 bytes. + /// \param[in] pAbi Used IABI instance. + /// \param[out] pattern Content of fill bytes. + /// \return Status message if operation succeeded. + /// \ingroup CAN + static int GetCanTpPattern(IABI* pAbi, BYTE& pattern); + + /// Get the supported audio connectors for TX. + /// \param[in] abi Used IABI instance. + /// \param[out] length Length of connector array. + /// \param[out] types Supported connectors. + /// Status message if operation succeeded. + /// \ingroup HW + static int GetMostAudioSupportedTxConnectors(IABI* pAbi, WORD& length, AudioConnectorType*& types); + + /// Retrieves all supported features in a space seperated string. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Feature list. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int GetSupportedFeatures(IABI* pAbi, char*& result); + + /// Sends a get command to the StressNIC. + /// \param[in] pAbi Used IABI instance. + /// \param[in] fblockId FBlock identifier of command. + /// \param[in] functionId Function identifier of command. + /// \param[out] length Payloadlength. + /// \param[out] payload Payload of function. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int StressNicFunctionGet(IABI* pAbi, BYTE fblockId, unsigned short functionId, WORD& length, BYTE*& payload); + + /// Sends a get command to the StressNIC. + /// \param[in] pAbi Used IABI instance. + /// \param[in] fblockId FBlock identifier of command. + /// \param[in] functionId Function identifier of command. + /// \param[in] requestLength Payload length of request. + /// \param[in] request Payload of request. + /// \param[out] responseLength Payload length of response. + /// \param[out] response Payload of response. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int StressNicFunctionGetExtended(IABI* pAbi, BYTE fblockId, unsigned short functionId, WORD requestLength, BYTE* request, WORD& responseLength, BYTE*& response); + + /// Get the volume of the selected audio connector. + /// \param[in] abi Used IABI instance. + /// \param[in] connector The selected audio connector type. + /// \param[in] isInput true if input volume should be modified, otherwise output volume is modified. + /// \param[out] volumeLeft Attenuation(-)/Gain(+) in db of left channel. + /// \param[out] volumeRight Attenuation(-)/Gain(+) in db of right channel. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetVolume(IABI* pAbi, AudioConnectorType connector, bool isInput, int& volumeLeft, int& volumeRight); + + /// Get the supported volume range of the selected audio connector.</summary> + /// \param[in] abi Used IABI instance. + /// \param[in] connector The selected audio connector type. + /// \param[in] isInput true if input volume should be modified, otherwise output volume is modified. + /// \param[out] minVolume Minimum supported Attenuation(-)/Gain(+) in db. + /// \param[out] maxVolume Maximum supported Attenuation(-)/Gain(+) in db. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetSupportedVolumeRange(IABI* pAbi, AudioConnectorType connector, bool isInput, int& minVolume, int& maxVolume); + + /// Sends a sequence to the ECL/Trigger line. Timestamps are absolute.</summary> + /// \param[in] abi Used IABI instance. + /// \param[in]length Length of sequence. + /// \param[in]sequence Sequence of high and low commands. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int SendAbsoluteTriggerSequence(IABI* pAbi, WORD length, AbsoluteTriggerCommand* sequence); + + /// Sends a sequence to the ECL/Trigger line. Timestamps are relative to the start of transmission.</summary> + /// \param[in] abi Used IABI instance. + /// \param[in]length Length of sequence. + /// \param[in]sequence Sequence of high and low commands. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int SendRelativeTriggerSequence(IABI* pAbi, WORD length, RelativeTriggerCommand* sequence); + }; + } + } +} +//@} +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// END OF FILE +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/K2LABI/ABI/ABICommandsEx.cpp b/K2LABI/ABI/ABICommandsEx.cpp new file mode 100644 index 0000000..9c9c190 --- /dev/null +++ b/K2LABI/ABI/ABICommandsEx.cpp @@ -0,0 +1,4813 @@ +#include <string.h> +#include "k2l-type.h" +#include "ABICommands.h" +#include "K2LABI.h" +#include "ResultParser.h" +#include "ABIFunctionDefinition.h" + +using namespace K2L::Automotive::ABI; + +int CABICommandsEx::AddCanTpReceiver(IABI* pAbi, unsigned short handle, Bus bus, unsigned int messageIdSrc, unsigned int messageIdDst, TPAddressingType addressingType) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[5]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + params[1].m_pData = &bus; + params[1].m_nLength = 1; + params[2].m_pData = &messageIdSrc; + params[2].m_nLength = 4; + params[3].m_pData = &messageIdDst; + params[3].m_nLength = 4; + params[4].m_pData = &addressingType; + params[4].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 5, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__AddCanTpReceiver, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::AddCanTpTransmitter(IABI* pAbi, unsigned short handle, Bus bus, unsigned int srcMessageId, unsigned int dstMessageId, TPAddressingType addressingType, unsigned short cycleTime, unsigned int totalNumber, unsigned short payloadLength, BYTE* payload) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[9]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + params[1].m_pData = &bus; + params[1].m_nLength = 1; + params[2].m_pData = &srcMessageId; + params[2].m_nLength = 4; + params[3].m_pData = &dstMessageId; + params[3].m_nLength = 4; + params[4].m_pData = &addressingType; + params[4].m_nLength = 1; + params[5].m_pData = &cycleTime; + params[5].m_nLength = 2; + params[6].m_pData = &totalNumber; + params[6].m_nLength = 4; + params[7].m_pData = &payloadLength; + params[7].m_nLength = 2; + params[8].m_pData = payload; + params[8].m_nLength = payloadLength; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 9, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__AddCanTpTransmitter, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::AddReceiver(IABI* pAbi, unsigned short handle, Bus bus, unsigned int param1, unsigned int param2) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[4]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + params[1].m_pData = &bus; + params[1].m_nLength = 1; + params[2].m_pData = ¶m1; + params[2].m_nLength = 4; + params[3].m_pData = ¶m2; + params[3].m_nLength = 4; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 4, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__AddReceiver, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::AddTransmitterEx(IABI* pAbi, unsigned short handle, Bus bus, unsigned short targetAddress, unsigned int messageId, unsigned int delay, unsigned short cycle, unsigned int totalNumber, unsigned short payloadLength, BYTE* payload) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[9]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + params[1].m_pData = &bus; + params[1].m_nLength = 1; + params[2].m_pData = &targetAddress; + params[2].m_nLength = 2; + params[3].m_pData = &messageId; + params[3].m_nLength = 4; + params[4].m_pData = &delay; + params[4].m_nLength = 4; + params[5].m_pData = &cycle; + params[5].m_nLength = 2; + params[6].m_pData = &totalNumber; + params[6].m_nLength = 4; + params[7].m_pData = &payloadLength; + params[7].m_nLength = 2; + params[8].m_pData = payload; + params[8].m_nLength = payloadLength; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 9, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__AddTransmitterEx, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::AddTxSweepSignal(IABI* pAbi, unsigned short handle, SignalType signalType, unsigned short firstBitPos, unsigned short lastBitPos, unsigned short stepsNum, int step, unsigned int initialValue, unsigned int repetitionsNumber) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[8]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + params[1].m_pData = &signalType; + params[1].m_nLength = 1; + params[2].m_pData = &firstBitPos; + params[2].m_nLength = 2; + params[3].m_pData = &lastBitPos; + params[3].m_nLength = 2; + params[4].m_pData = &stepsNum; + params[4].m_nLength = 2; + params[5].m_pData = &step; + params[5].m_nLength = 4; + params[6].m_pData = &initialValue; + params[6].m_nLength = 4; + params[7].m_pData = &repetitionsNumber; + params[7].m_nLength = 4; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 8, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__AddTxSweepSignal, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::ChangeCycleTime(IABI* pAbi, unsigned short handle, unsigned short cycle) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + params[1].m_pData = &cycle; + params[1].m_nLength = 2; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__ChangeCycleTime, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::ChangeTransmitterData(IABI* pAbi, unsigned short handle, unsigned short payloadLength, BYTE* payload) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[3]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + params[1].m_pData = &payloadLength; + params[1].m_nLength = 2; + params[2].m_pData = payload; + params[2].m_nLength = payloadLength; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 3, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__ChangeTransmitterData, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::ClearCanTpPattern(IABI* pAbi) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__ClearCanTpPattern, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::Delete(IABI* pAbi, unsigned short handle) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__Delete, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::DeleteTxSweepSignals(IABI* pAbi, unsigned short handle) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__DeleteTxSweepSignals, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::EnableFlexRayTx(IABI* pAbi, bool enabled) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &enabled; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__EnableFlexRayTx, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::EnableMepEthernetBridge(IABI* pAbi, bool isEnabled) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &isEnabled; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__EnableMepEthernetBridge, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::EnableMepEthernetBridgeExtended(IABI* pAbi, bool isEnabled, MepBridgeOptions options) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &isEnabled; + params[0].m_nLength = 1; + params[1].m_pData = &options; + params[1].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__EnableMepEthernetBridgeExtended, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::EnableMostSpy(IABI* pAbi, bool status, bool control, bool async, bool sync) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[4]; + params[0].m_pData = &status; + params[0].m_nLength = 1; + params[1].m_pData = &control; + params[1].m_nLength = 1; + params[2].m_pData = &async; + params[2].m_nLength = 1; + params[3].m_pData = &sync; + params[3].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 4, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__EnableMostSpy, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetBoundary(IABI* pAbi, BYTE& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetBoundary, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetCanBaseFrequency(IABI* pAbi, Bus bus, unsigned int& result) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetCanBaseFrequency, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(unsigned int*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetCanBusCount(IABI* pAbi, unsigned int& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetCanBusCount, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(unsigned int*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetCanSpeed(IABI* pAbi, Bus bus, CanSpeed& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetCanSpeed, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = (K2L::Automotive::ABI::CanSpeed)*pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetCanTransceiver(IABI* pAbi, Bus bus, CanTransceiver& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetCanTransceiver, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = (K2L::Automotive::ABI::CanTransceiver)*pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetDeviceMode(IABI* pAbi, MostMode& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetDeviceMode, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = (K2L::Automotive::ABI::MostMode)*pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetFirmwareVersion(IABI* pAbi, char*& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetFirmwareVersion, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = new char[resultLen+1]; + memcpy(result, pRes, resultLen+1); + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetFlexRayBusCount(IABI* pAbi, unsigned int& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetFlexRayBusCount, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(unsigned int*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetGroupAddr(IABI* pAbi, BYTE& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetGroupAddr, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetGwAddress(IABI* pAbi, char*& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetGwAddress, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = new char[resultLen+1]; + memcpy(result, pRes, resultLen+1); + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetHardwareVersion(IABI* pAbi, char*& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetHardwareVersion, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = new char[resultLen+1]; + memcpy(result, pRes, resultLen+1); + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetInformation(IABI* pAbi, BoardInformation info, char*& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &info; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetInformation, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = new char[resultLen+1]; + memcpy(result, pRes, resultLen+1); + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetInternalState(IABI* pAbi, Parameter parameter, unsigned int& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = ¶meter; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__GetInternalState, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(unsigned int*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetIpAddress(IABI* pAbi, char*& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetIpAddress, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = new char[resultLen+1]; + memcpy(result, pRes, resultLen+1); + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetLinBusCount(IABI* pAbi, unsigned int& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetLinBusCount, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(unsigned int*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetLinConfigurationName(IABI* pAbi, Bus bus, char*& result) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetLinConfigurationName, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = new char[resultLen+1]; + memcpy(result, pRes, resultLen+1); + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetLinSpeed(IABI* pAbi, Bus bus, unsigned int& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetLinSpeed, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(unsigned int*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetLogicalNodeAddr(IABI* pAbi, unsigned short& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetLogicalNodeAddr, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(unsigned short*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetMostControlChannelHighLevelRetry(IABI* pAbi, BYTE& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetMostControlChannelHighLevelRetry, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetMostControlChannelLowLevelRetry(IABI* pAbi, BYTE& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetMostControlChannelLowLevelRetry, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetMostControlChannelMidLevelRetry(IABI* pAbi, BYTE& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetMostControlChannelMidLevelRetry, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetMostFrequency(IABI* pAbi, MostSamplingFrequency& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetMostFrequency, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = (K2L::Automotive::ABI::MostSamplingFrequency)*pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetMostIlluminationLevel(IABI* pAbi, MostIlluminationLevel& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetMostIlluminationLevel, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = (K2L::Automotive::ABI::MostIlluminationLevel)*pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetMostMacAddress(IABI* pAbi, unsigned long long& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetMostMacAddress, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(unsigned long long*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetMostShutdownReason(IABI* pAbi, BYTE& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetMostShutdownReason, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetMostSpeedGrade(IABI* pAbi, unsigned int& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetMostSpeedGrade, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(unsigned int*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetMPR(IABI* pAbi, BYTE& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetMPR, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetMuteState(IABI* pAbi, AudioConnectorType connector, bool isInput, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &connector; + params[0].m_nLength = 1; + params[1].m_pData = &isInput; + params[1].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetMuteState, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetNetMask(IABI* pAbi, char*& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetNetMask, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = new char[resultLen+1]; + memcpy(result, pRes, resultLen+1); + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetNPR(IABI* pAbi, BYTE& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__GetNPR, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetParameter(IABI* pAbi, char* key, char*& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = (void*) key; + params[0].m_nLength = strlen(key) + 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetParameter, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = new char[resultLen+1]; + memcpy(result, pRes, resultLen+1); + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetParameterKeys(IABI* pAbi, char*& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetParameterKeys, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = new char[resultLen+1]; + memcpy(result, pRes, resultLen+1); + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetParameterValues(IABI* pAbi, char* key, char*& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = (void*) key; + params[0].m_nLength = strlen(key) + 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetParameterValues, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = new char[resultLen+1]; + memcpy(result, pRes, resultLen+1); + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetRunningTime(IABI* pAbi, unsigned long long& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetRunningTime, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(unsigned long long*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetSerialNumber(IABI* pAbi, char*& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetSerialNumber, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = new char[resultLen+1]; + memcpy(result, pRes, resultLen+1); + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetTimeStamp(IABI* pAbi, unsigned long long& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetTimeStamp, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(unsigned long long*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetTimingSynchronisationMode(IABI* pAbi, TimingSynchronisationMode& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetTimingSynchronisationMode, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = (K2L::Automotive::ABI::TimingSynchronisationMode)*pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::GetTriggerLevel(IABI* pAbi, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__GetTriggerLevel, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::HasAllocationTableSupport(IABI* pAbi, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__HasAllocationTableSupport, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::HasMultipleStreamInSupport(IABI* pAbi, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__HasMultipleStreamInSupport, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::HasRedirectStreamInToOutSupport(IABI* pAbi, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__HasRedirectStreamInToOutSupport, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::Identify(IABI* pAbi) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__Identify, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::IsBusStarted(IABI* pAbi, Bus bus, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__IsBusStarted, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::IsCanTransceiverSupported(IABI* pAbi, Bus bus, CanTransceiver transceiver, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + params[1].m_pData = &transceiver; + params[1].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__IsCanTransceiverSupported, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::IsFlexRaySynchronized(IABI* pAbi, Bus bus, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__IsFlexRaySynchronized, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::IsFlexRayTxEnabled(IABI* pAbi, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__IsFlexRayTxEnabled, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::IsLinMaster(IABI* pAbi, Bus bus, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__IsLinMaster, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::IsMepEthernetBridgeEnabled(IABI* pAbi, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__IsMepEthernetBridgeEnabled, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::IsMostNodeSupported(IABI* pAbi, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__IsMostNodeSupported, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::IsMostSpySupported(IABI* pAbi, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__IsMostSpySupported, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::IsMostStressSupported(IABI* pAbi, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__IsMostStressSupported, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::IsNetOn(IABI* pAbi, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__IsNetOn, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::IsRelayClosed(IABI* pAbi, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__IsRelayClosed, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::IsStableLock(IABI* pAbi, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__IsStableLock, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::IsTxPayloadFilterEnabled(IABI* pAbi, Bus bus, bool& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__IsTxPayloadFilterEnabled, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = 0 != *(BYTE*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::MostAudioAllocate(IABI* pAbi, AudioBandwidth bandwidth) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bandwidth; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__MostAudioAllocate, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::MostAudioRxConnect(IABI* pAbi, AudioBandwidth bandwidth, unsigned int label) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &bandwidth; + params[0].m_nLength = 1; + params[1].m_pData = &label; + params[1].m_nLength = 4; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__MostAudioRxConnect, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::MostAudioRxConnectExt(IABI* pAbi, AudioBandwidth bandwidth, unsigned int label) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &bandwidth; + params[0].m_nLength = 1; + params[1].m_pData = &label; + params[1].m_nLength = 4; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__MostAudioRxConnectExt, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::MostAudioRxDisconnect(IABI* pAbi, unsigned int label) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &label; + params[0].m_nLength = 4; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__MostAudioRxDisconnect, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::MostAudioTxAllocateConnect(IABI* pAbi, AudioBandwidth bandwidth) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bandwidth; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__MostAudioTxAllocateConnect, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::MostAudioTxAllocateConnect(IABI* pAbi, AudioBandwidth bandwidth, AudioConnectorType connector) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &bandwidth; + params[0].m_nLength = 1; + params[1].m_pData = &connector; + params[1].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__MostAudioTxAllocateConnect, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::MostAudioTxConnect(IABI* pAbi, AudioBandwidth bandwidth, unsigned int label) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &bandwidth; + params[0].m_nLength = 1; + params[1].m_pData = &label; + params[1].m_nLength = 4; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__MostAudioTxConnect, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::MostAudioTxDisconnect(IABI* pAbi, unsigned int label) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &label; + params[0].m_nLength = 4; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__MostAudioTxDisconnect, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::RebootFirmware(IABI* pAbi) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__RebootFirmware, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::ResetMostShutdownReason(IABI* pAbi) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__ResetMostShutdownReason, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::ResetTimeStamp(IABI* pAbi) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__ResetTimeStamp, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SelectGroup(IABI* pAbi, BYTE group) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &group; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__SelectGroup, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SendCanTpMessage(IABI* pAbi, unsigned short handle, Bus bus, unsigned int source, unsigned int destination, TPAddressingType type, unsigned short payloadLength, BYTE* payload) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[7]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + params[1].m_pData = &bus; + params[1].m_nLength = 1; + params[2].m_pData = &source; + params[2].m_nLength = 4; + params[3].m_pData = &destination; + params[3].m_nLength = 4; + params[4].m_pData = &type; + params[4].m_nLength = 1; + params[5].m_pData = &payloadLength; + params[5].m_nLength = 2; + params[6].m_pData = payload; + params[6].m_nLength = payloadLength; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 7, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__SendCanTpMessage, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SendMessage(IABI* pAbi, unsigned short handle, Bus bus, unsigned short targetAddress, unsigned int messageId, unsigned short payloadLength, BYTE* payload) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[6]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + params[1].m_pData = &bus; + params[1].m_nLength = 1; + params[2].m_pData = &targetAddress; + params[2].m_nLength = 2; + params[3].m_pData = &messageId; + params[3].m_nLength = 4; + params[4].m_pData = &payloadLength; + params[4].m_nLength = 2; + params[5].m_pData = payload; + params[5].m_nLength = payloadLength; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 6, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__SendMessage, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SendMostHighExtendedMessage(IABI* pAbi, unsigned short handle, unsigned short targetAddress, BYTE fblockID, BYTE instanceID, unsigned short functionID, BYTE opType, unsigned short minDelay, unsigned short maxDelay, BYTE priority, MostMhpOptions options, unsigned int totalPacketLength, unsigned short payloadLength, BYTE* payload) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[13]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + params[1].m_pData = &targetAddress; + params[1].m_nLength = 2; + params[2].m_pData = &fblockID; + params[2].m_nLength = 1; + params[3].m_pData = &instanceID; + params[3].m_nLength = 1; + params[4].m_pData = &functionID; + params[4].m_nLength = 2; + params[5].m_pData = &opType; + params[5].m_nLength = 1; + params[6].m_pData = &minDelay; + params[6].m_nLength = 2; + params[7].m_pData = &maxDelay; + params[7].m_nLength = 2; + params[8].m_pData = &priority; + params[8].m_nLength = 1; + params[9].m_pData = &options; + params[9].m_nLength = 1; + params[10].m_pData = &totalPacketLength; + params[10].m_nLength = 4; + params[11].m_pData = &payloadLength; + params[11].m_nLength = 2; + params[12].m_pData = payload; + params[12].m_nLength = payloadLength; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 13, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__SendMostHighExtendedMessage, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SendMostHighExtMessage(IABI* pAbi, unsigned short handle, unsigned short targetAddress, BYTE fblockID, BYTE instanceID, unsigned short functionID, BYTE opType, unsigned int totalPacketLength, unsigned short payloadLength, BYTE* payload) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[9]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + params[1].m_pData = &targetAddress; + params[1].m_nLength = 2; + params[2].m_pData = &fblockID; + params[2].m_nLength = 1; + params[3].m_pData = &instanceID; + params[3].m_nLength = 1; + params[4].m_pData = &functionID; + params[4].m_nLength = 2; + params[5].m_pData = &opType; + params[5].m_nLength = 1; + params[6].m_pData = &totalPacketLength; + params[6].m_nLength = 4; + params[7].m_pData = &payloadLength; + params[7].m_nLength = 2; + params[8].m_pData = payload; + params[8].m_nLength = payloadLength; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 9, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__SendMostHighExtMessage, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SendMostMepExtMessage(IABI* pAbi, unsigned short handle, BYTE retryCount, BYTE priority, unsigned short payloadLength, BYTE* payload) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[5]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + params[1].m_pData = &retryCount; + params[1].m_nLength = 1; + params[2].m_pData = &priority; + params[2].m_nLength = 1; + params[3].m_pData = &payloadLength; + params[3].m_nLength = 2; + params[4].m_pData = payload; + params[4].m_nLength = payloadLength; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 5, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__SendMostMepExtMessage, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SendMostMepMessage(IABI* pAbi, unsigned short handle, unsigned short payloadLength, BYTE* payload) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[3]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + params[1].m_pData = &payloadLength; + params[1].m_nLength = 2; + params[2].m_pData = payload; + params[2].m_nLength = payloadLength; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 3, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__SendMostMepMessage, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetBoundary(IABI* pAbi, BYTE boundary) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &boundary; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__SetBoundary, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetCanTpPattern(IABI* pAbi, BYTE pattern) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &pattern; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__SetCanTpPattern, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetCanTpRxConfig(IABI* pAbi, BYTE blockSize, BYTE separationTime, unsigned short consecutiveFrameTimeout) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[3]; + params[0].m_pData = &blockSize; + params[0].m_nLength = 1; + params[1].m_pData = &separationTime; + params[1].m_nLength = 1; + params[2].m_pData = &consecutiveFrameTimeout; + params[2].m_nLength = 2; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 3, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__SetCanTpRxConfig, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetCanTpTxConfig(IABI* pAbi, unsigned short flowControlTimeout, unsigned short clearToSendTimeout) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &flowControlTimeout; + params[0].m_nLength = 2; + params[1].m_pData = &clearToSendTimeout; + params[1].m_nLength = 2; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__SetCanTpTxConfig, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetDeviceMode(IABI* pAbi, MostMode deviceMode, DeviceModeOptions options) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &deviceMode; + params[0].m_nLength = 1; + params[1].m_pData = &options; + params[1].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__SetDeviceMode, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetGroupAddr(IABI* pAbi, unsigned short groupAddress) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &groupAddress; + params[0].m_nLength = 2; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__SetGroupAddr, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetLogicalNodeAddr(IABI* pAbi, unsigned short nodeAddress) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &nodeAddress; + params[0].m_nLength = 2; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__SetLogicalNodeAddr, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetMostControlChannelHighLevelRetry(IABI* pAbi, BYTE retryCount) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &retryCount; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__SetMostControlChannelHighLevelRetry, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetMostControlChannelLowLevelRetry(IABI* pAbi, BYTE retryCount) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &retryCount; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__SetMostControlChannelLowLevelRetry, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetMostControlChannelMidLevelRetry(IABI* pAbi, BYTE retryCount) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &retryCount; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__SetMostControlChannelMidLevelRetry, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetMostFrequency(IABI* pAbi, MostSamplingFrequency frequency) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &frequency; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__SetMostFrequency, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetMostIlluminationLevel(IABI* pAbi, MostIlluminationLevel level) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &level; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__SetMostIlluminationLevel, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetMostMacAddress(IABI* pAbi, unsigned long long macAddress, bool isPersistent) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &macAddress; + params[0].m_nLength = 8; + params[1].m_pData = &isPersistent; + params[1].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__SetMostMacAddress, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetMuteState(IABI* pAbi, AudioConnectorType connector, bool isInput, bool mute) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[3]; + params[0].m_pData = &connector; + params[0].m_nLength = 1; + params[1].m_pData = &isInput; + params[1].m_nLength = 1; + params[2].m_pData = &mute; + params[2].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 3, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__SetMuteState, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetParameter(IABI* pAbi, char* key, char* newValue) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = (void*) key; + params[0].m_nLength = strlen(key) + 1; + params[1].m_pData = (void*) newValue; + params[1].m_nLength = strlen(newValue) + 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__SetParameter, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetRelay(IABI* pAbi, bool switchOn, unsigned long long& result) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &switchOn; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__SetRelay, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(unsigned long long*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetTimeStamp(IABI* pAbi, unsigned long long timestamp) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = ×tamp; + params[0].m_nLength = 8; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__SetTimeStamp, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetTimingSynchronisationMode(IABI* pAbi, TimingSynchronisationMode mode) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &mode; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__SetTimingSynchronisationMode, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetTriggerLevel(IABI* pAbi, bool isActive) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &isActive; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__SetTriggerLevel, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetTxPayloadFilter(IABI* pAbi, Bus bus, bool isEnabled) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + params[1].m_pData = &isEnabled; + params[1].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__SetTxPayloadFilter, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SetVolume(IABI* pAbi, AudioConnectorType connector, bool isInput, bool modifyLeft, bool modifyRight, int volume) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[5]; + params[0].m_pData = &connector; + params[0].m_nLength = 1; + params[1].m_pData = &isInput; + params[1].m_nLength = 1; + params[2].m_pData = &modifyLeft; + params[2].m_nLength = 1; + params[3].m_pData = &modifyRight; + params[3].m_nLength = 1; + params[4].m_pData = &volume; + params[4].m_nLength = 4; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 5, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__SetVolume, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::ShutdownMost(IABI* pAbi) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__ShutdownMost, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::Start(IABI* pAbi, unsigned short handle) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__Start, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StartCan(IABI* pAbi, Bus bus, CanTransceiver transceiverType, CanSpeed speed) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[3]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + params[1].m_pData = &transceiverType; + params[1].m_nLength = 1; + params[2].m_pData = &speed; + params[2].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 3, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__StartCan, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StartCanExt(IABI* pAbi, Bus bus, CanTransceiver transceiverType, BYTE brp, BYTE tseg1, BYTE tseg2, BYTE sjw) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[6]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + params[1].m_pData = &transceiverType; + params[1].m_nLength = 1; + params[2].m_pData = &brp; + params[2].m_nLength = 1; + params[3].m_pData = &tseg1; + params[3].m_nLength = 1; + params[4].m_pData = &tseg2; + params[4].m_nLength = 1; + params[5].m_pData = &sjw; + params[5].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 6, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__StartCanExt, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StartFlexRay(IABI* pAbi, unsigned short payloadLength, BYTE* blob) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &payloadLength; + params[0].m_nLength = 2; + params[1].m_pData = blob; + params[1].m_nLength = payloadLength; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__StartFlexRay, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StartLin(IABI* pAbi, Bus bus, unsigned short payloadLength, BYTE* blob) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[3]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + params[1].m_pData = &payloadLength; + params[1].m_nLength = 2; + params[2].m_pData = blob; + params[2].m_nLength = payloadLength; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 3, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__StartLin, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StartLinSpy(IABI* pAbi, Bus bus, unsigned int baudrate) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[2]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + params[1].m_pData = &baudrate; + params[1].m_nLength = 4; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 2, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__StartLinSpy, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StartMost(IABI* pAbi, MostMode mode) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &mode; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__StartMost, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StartupMost(IABI* pAbi) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__StartupMost, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::Stop(IABI* pAbi, unsigned short handle) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &handle; + params[0].m_nLength = 2; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__Stop, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StopCan(IABI* pAbi, Bus bus) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__StopCan, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StopFlexRay(IABI* pAbi) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__StopFlexRay, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StopLin(IABI* pAbi, Bus bus) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__StopLin, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StopLinSpy(IABI* pAbi, Bus bus) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)Board, (BYTE)FunId__StopLinSpy, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StopMost(IABI* pAbi) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__StopMost, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StressNicDeviceModeGet(IABI* pAbi, StressNicMode& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)StressNic, (BYTE)FunId__StressNicDeviceModeGet, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = (K2L::Automotive::ABI::StressNicMode)*pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StressNicDeviceModeSet(IABI* pAbi, StressNicMode mode) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &mode; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)StressNic, (BYTE)FunId__StressNicDeviceModeSet, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StressNicFunctionSet(IABI* pAbi, BYTE fblockId, unsigned short functionId, unsigned short payloadLength, BYTE* payload) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[4]; + params[0].m_pData = &fblockId; + params[0].m_nLength = 1; + params[1].m_pData = &functionId; + params[1].m_nLength = 2; + params[2].m_pData = &payloadLength; + params[2].m_nLength = 2; + params[3].m_pData = payload; + params[3].m_nLength = payloadLength; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 4, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)StressNic, (BYTE)FunId__StressNicFunctionSet, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StressNicGroupAddressGet(IABI* pAbi, unsigned short& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)StressNic, (BYTE)FunId__StressNicGroupAddressGet, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(unsigned short*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StressNicGroupAddressSet(IABI* pAbi, unsigned short groupAddress) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &groupAddress; + params[0].m_nLength = 2; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)StressNic, (BYTE)FunId__StressNicGroupAddressSet, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StressNicNodeAddressGet(IABI* pAbi, unsigned short& result) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + //ParamDef params[0]; + + //pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 0, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)StressNic, (BYTE)FunId__StressNicNodeAddressGet, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + result = *(unsigned short*)pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StressNicNodeAddressSet(IABI* pAbi, unsigned short nodeAddress) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &nodeAddress; + params[0].m_nLength = 2; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)StressNic, (BYTE)FunId__StressNicNodeAddressSet, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::StressNicSendMessage(IABI* pAbi, unsigned short deviceId, BYTE fblockId, BYTE instance, unsigned short functionId, BYTE opType, unsigned short payloadLength, BYTE* payload) +{ + if (!pAbi) { return 0; } + + //if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[7]; + params[0].m_pData = &deviceId; + params[0].m_nLength = 2; + params[1].m_pData = &fblockId; + params[1].m_nLength = 1; + params[2].m_pData = &instance; + params[2].m_nLength = 1; + params[3].m_pData = &functionId; + params[3].m_nLength = 2; + params[4].m_pData = &opType; + params[4].m_nLength = 1; + params[5].m_pData = &payloadLength; + params[5].m_nLength = 2; + params[6].m_pData = payload; + params[6].m_nLength = payloadLength; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 7, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)StressNic, (BYTE)FunId__StressNicSendMessage, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::SwitchBypassMode(IABI* pAbi, BypassMode bypassMode) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[1]; + params[0].m_pData = &bypassMode; + params[0].m_nLength = 1; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 1, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)NetServices, (BYTE)FunId__SwitchBypassMode, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} + +int CABICommandsEx::WriteBusConfiguration(IABI* pAbi, Bus bus, unsigned short payloadLength, BYTE* configuration) +{ + if (!pAbi) { return 0; } + + if (pAbi->IsSpyMode()) { return 0; } + + int resultLen = 0; + BYTE error = 0; + + ParamDef* pParams = NULL; + ParamDef params[3]; + params[0].m_pData = &bus; + params[0].m_nLength = 1; + params[1].m_pData = &payloadLength; + params[1].m_nLength = 2; + params[2].m_pData = configuration; + params[2].m_nLength = payloadLength; + + pParams = params; + + int bufferLength = 0; + BYTE* pBuffer = CResultParser::ToByteArray(pParams, 3, bufferLength); + + BYTE* pRes = pAbi->SendRequest((BYTE)TestMaster, (BYTE)FunId__WriteBusConfiguration, pBuffer, bufferLength, resultLen, error); + delete pBuffer; + + if (!pRes) + { + pAbi->EndRequest(); + return -1; + } + + //result = pRes; + + pAbi->EndRequest(); + + return error; +} diff --git a/K2LABI/ABI/ABICommandsEx.h b/K2LABI/ABI/ABICommandsEx.h new file mode 100644 index 0000000..c2c2f88 --- /dev/null +++ b/K2LABI/ABI/ABICommandsEx.h @@ -0,0 +1,1158 @@ +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// K2L GmbH +/// +/// \file +/// This file contains the api of all abi commands. +/// +/// \ingroup ABICommands +/// +/// \par COPYRIGHT (c) 2000-2011 by K2L GmbH +/// All rights reserved. +/// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// Alle Rechte an der Software verbleiben bei der K2L GmbH. +/// +/// Die K2L GmbH raeumt dem Lizenznehmer nach vollstaendiger +/// Bezahlung der Lizenzgebuehr ein nicht ausschliessliches, +/// unwiderrufliches, nicht uebertragbares, zeitlich und geografisch +/// nicht beschraenktes Recht zur Nutzung der jeweils +/// auftragsgegenstaendlichen Software innerhalb des Lizenznehmers ein. +/// +/// Die Weitergabe des Nutzungsrechts durch den Lizenznehmer ist auf +/// dessen Zulieferer beschraenkt. Die Zulieferer sind zu verpflichten, +/// die Software nur im Rahmen von Projekten fuer den Lizenznehmer +/// zu verwenden; weitere Rechte der Zulieferer sind auszuschliessen. +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//@{ + +#pragma once + +#include "K2LABI.h" +#include <string> + +using namespace std; + +namespace K2L +{ + namespace Automotive + { + namespace ABI + { + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// \brief This class contains some commands for controlling the device. +/// \note Use CABICommands instead, so you have access to all commands include of CABICommandsEx. +/// \ingroup ABICommands +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +class K2LABI_API CABICommandsEx +{ + +public: + + /// Adds receiving rule for the CAN TP bus into the current group. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of the receiving rule. + /// \param[in] bus Receiving bus. + /// \param[in] messageIdSrc Source message id. + /// \param[in] messageIdDst Destination message id. + /// \param[in] addressingType TP addressing type. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int AddCanTpReceiver(IABI* pAbi, unsigned short handle, Bus bus, unsigned int messageIdSrc, unsigned int messageIdDst, TPAddressingType addressingType); + + /// Adds CAN TP transmitting rule to the list of the rules from the current group. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of transmitting rule. + /// \param[in] bus Transmitting bus. + /// \param[in] srcMessageId Source message id. + /// \param[in] dstMessageId Destination message id. + /// \param[in] addressingType TP addressing type. + /// \param[in] cycleTime Cycle time in milliseconds for cyclic message sending. + /// \param[in] totalNumber Number of time the message is sent, 0 means endless transmission. + /// \param[in] payloadLength Length of payload. + /// \param[in] payload Payload data. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int AddCanTpTransmitter(IABI* pAbi, unsigned short handle, Bus bus, unsigned int srcMessageId, unsigned int dstMessageId, TPAddressingType addressingType, unsigned short cycleTime, unsigned int totalNumber, unsigned short payloadLength, BYTE* payload); + + /// Adds receiving rule into the current group. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of the receiving rule. + /// \param[in] bus Receiving bus. + /// \param[in] param1 Parameter 1. + /// \param[in] param2 Parameter 2. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note MOST: param1: mask (0 means all ids; 0xFFFFFFFF means this id). param2: message identifier value. + /// \note FlexRay: param1: mask (0 means all ids; 0xFFFFFFFF means this id). param2: message identifier value. + /// \note CAN: param1: minimal message identifier. param2: maximal identifier. + /// \note LIN: param1: message identifier (0xFF means all ids). param2: Not used. + /// \note LINTP: param1: Node address (0xFF means all NADs). param2: Not used. + /// \note MEP: param1: High part of MAC address. param2: Low part of MAC address. If param1 is 0xFFFFFFF and param2 are 0xFFFF then all messages will be let through. + /// \ingroup OBJ + static int AddReceiver(IABI* pAbi, unsigned short handle, Bus bus, unsigned int param1, unsigned int param2); + + /// Adds transmitting rule to the list of the rules from the current group. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of transmitting rule. + /// \param[in] bus Transmitting bus. + /// \param[in] targetAddress Target address. + /// \param[in] messageId Message identifier. + /// \param[in] delay Time in milliseconds between starting of transmitter and sending of the first message. + /// \param[in] cycle Cycle time in milliseconds for cyclic message sending. + /// \param[in] totalNumber Number of time the message is sent, 0 means endless transmission. + /// \param[in] payloadLength Length of payload. + /// \param[in] payload Payload data. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int AddTransmitterEx(IABI* pAbi, unsigned short handle, Bus bus, unsigned short targetAddress, unsigned int messageId, unsigned int delay, unsigned short cycle, unsigned int totalNumber, unsigned short payloadLength, BYTE* payload); + + /// Adds sweep signal for the transmitting rule. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of the transceiver you want to add signal to. + /// \param[in] signalType Signal type. There are several types of a signals. + /// \param[in] firstBitPos First bit position of the sweep signal. + /// \param[in] lastBitPos Last bit position of the sweep signal. + /// \param[in] stepsNum Number of steps between minimal and maximal value of the signal sequence. This parameter is ignored for the Bit Shift signal type. + /// \param[in] step Step between two signals. Negative value descends signal value. This parameter is ignored for the Bit Shift signal type. + /// \param[in] initialValue Initial value of the signal. This parameter is ignored for the Bit Shift signal type. + /// \param[in] repetitionsNumber Number of messages sent before this signal is incremented according to signal type. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int AddTxSweepSignal(IABI* pAbi, unsigned short handle, SignalType signalType, unsigned short firstBitPos, unsigned short lastBitPos, unsigned short stepsNum, int step, unsigned int initialValue, unsigned int repetitionsNumber); + + /// Changes cycle time of the given transmitting rule. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of transmitting rule. + /// \param[in] cycle Cycle time in milliseconds for cyclic message sending. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int ChangeCycleTime(IABI* pAbi, unsigned short handle, unsigned short cycle); + + /// Changes data of existing transmitter. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of the transmitting rule. + /// \param[in] payloadLength Length of new payload. + /// \param[in] payload New payload data. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int ChangeTransmitterData(IABI* pAbi, unsigned short handle, unsigned short payloadLength, BYTE* payload); + + /// Clears CAN TP pattern. + /// \param[in] pAbi Used IABI instance. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup CANTP + static int ClearCanTpPattern(IABI* pAbi); + + /// Deletes one or more transmitting or receiving rules. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of object you want to delete. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note If handle is zero all transmitting and receiving rules from the active group are deleted. + /// \ingroup OBJ + static int Delete(IABI* pAbi, unsigned short handle); + + /// Deletes all sweep signals from an transmitting rule. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of transmitting rule where the sweep signals should be deleted. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int DeleteTxSweepSignals(IABI* pAbi, unsigned short handle); + + /// Enables FlexRay tx messages. + /// \param[in] pAbi Used IABI instance. + /// \param[in] enabled TRUE if FlexRay tx messages should be enabled, otherwise FALSE. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup FR + static int EnableFlexRayTx(IABI* pAbi, bool enabled); + + /// Enables/Disables MEP<->Ethernet Bridge. + /// \param[in] pAbi Used IABI instance. + /// \param[in] isEnabled TRUE if bridge should be activated otherwise FALSE. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note Only available for MOST 150. + /// \ingroup MOST + static int EnableMepEthernetBridge(IABI* pAbi, bool isEnabled); + + /// Enables/Disables MEP<->Ethernet Bridge. + /// \param[in] pAbi Used IABI instance. + /// \param[in] isEnabled TRUE if bridge should be activated otherwise FALSE. + /// \param[in] options Options to activate. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note Only available for MOST 150. + /// \ingroup MOST + static int EnableMepEthernetBridgeExtended(IABI* pAbi, bool isEnabled, MepBridgeOptions options); + + /// Set the channels of MOST Spy that are activated. + /// \param[in] pAbi Used IABI instance. + /// \param[in] status Status channel. + /// \param[in] control Control channel. + /// \param[in] async Asynchronous channel. + /// \param[in] sync Synchronous channel. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int EnableMostSpy(IABI* pAbi, bool status, bool control, bool async, bool sync); + + /// Gets the current value of the MOST boundary. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Boundary value (SBC). + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetBoundary(IABI* pAbi, BYTE& result); + + /// Gets base frqeuency of CAN cell. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Selected channel. + /// \param[out] result Returns base frquency of CAN cell. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup CAN + static int GetCanBaseFrequency(IABI* pAbi, Bus bus, unsigned int& result); + + /// Retrieves the count of available CAN buses. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Count of available CAN buses. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup CAN + static int GetCanBusCount(IABI* pAbi, unsigned int& result); + + /// Gets the actual selected can speed for the given CAN bus. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Selected CAN channel. + /// \param[out] result Selected baudrate. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup CAN + static int GetCanSpeed(IABI* pAbi, Bus bus, CanSpeed& result); + + /// Gets the actual selected transceiver type for the given CAN bus. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Selected CAN channel. + /// \param[out] result Selected transcevier type. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup CAN + static int GetCanTransceiver(IABI* pAbi, Bus bus, CanTransceiver& result); + + /// Gets the MOST mode of the device. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Actual MOST mode, determinates the mode of the INIC. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetDeviceMode(IABI* pAbi, MostMode& result); + + /// Gets the firmware version of device. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Firmware version of device. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int GetFirmwareVersion(IABI* pAbi, char*& result); + + /// Retrieves the count of available FlexRay buses. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Count of available FlexRay buses. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup FR + static int GetFlexRayBusCount(IABI* pAbi, unsigned int& result); + + /// Gets the MOST group address of device. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Group address of device. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetGroupAddr(IABI* pAbi, BYTE& result); + + /// Gets the Standard gateway IP address of device. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Standard gateway address. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int GetGwAddress(IABI* pAbi, char*& result); + + /// Gets the hardware version of device. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Hardware version of device. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int GetHardwareVersion(IABI* pAbi, char*& result); + + /// Retrieves various information from the Automotive Bus Interface. + /// \param[in] pAbi Used IABI instance. + /// \param[in] info Identifier of requested information. + /// \param[out] result Requested information. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int GetInformation(IABI* pAbi, BoardInformation info, char*& result); + + /// Retrieves internal amount of error events occurred in the the ABI firmware. Calling this method, will automatically clear the error counter to zero. + /// \param[in] pAbi Used IABI instance. + /// \param[in] parameter Module to retrieve state of. + /// \param[out] result Value of the selected parameter. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int GetInternalState(IABI* pAbi, Parameter parameter, unsigned int& result); + + /// Gets the IP address of device. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result IP address of device. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int GetIpAddress(IABI* pAbi, char*& result); + + /// Retrieves the count of available LIN buses. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Count of available LIN buses. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup LIN + static int GetLinBusCount(IABI* pAbi, unsigned int& result); + + /// Returns name of current used LIN configuration. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Selected channel. + /// \param[out] result Returns name of current used LIN configuration. If no config is used an empty string will be returned. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup LIN + static int GetLinConfigurationName(IABI* pAbi, Bus bus, char*& result); + + /// Retrieves the baud rate configured for the chossen LIN bus. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Selected LIN channel. + /// \param[out] result Baud rate of the LIN channel, represented in bit per second. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup LIN + static int GetLinSpeed(IABI* pAbi, Bus bus, unsigned int& result); + + /// Gets the logical MOST node address of device. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Logical node address of device. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetLogicalNodeAddr(IABI* pAbi, unsigned short& result); + + /// Get the count of high level retries. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Actual count of high level retries. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetMostControlChannelHighLevelRetry(IABI* pAbi, BYTE& result); + + /// Get the count of low level retries. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Actual count of low level retries. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetMostControlChannelLowLevelRetry(IABI* pAbi, BYTE& result); + + /// Get the count of mid level retries. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Actual count of mid level retries. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetMostControlChannelMidLevelRetry(IABI* pAbi, BYTE& result); + + /// Get the frequency of MOST. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Actual MOST frequency. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetMostFrequency(IABI* pAbi, MostSamplingFrequency& result); + + /// Retrieves the MOST illumination level. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result MOST illumination level. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetMostIlluminationLevel(IABI* pAbi, MostIlluminationLevel& result); + + /// Get MAC address of MOST node. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result MAC address of MOST node. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetMostMacAddress(IABI* pAbi, unsigned long long& result); + + /// Get the shutdown reason of INIC. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Shutdown reason of INIC. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note Only available for MOST 150. + /// \ingroup MOST + static int GetMostShutdownReason(IABI* pAbi, BYTE& result); + + /// Retrieves the supported MOST speed grade. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Speed grade of MOST. Returns 0 if not available. E.g. 50 means MOST50. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetMostSpeedGrade(IABI* pAbi, unsigned int& result); + + /// Gets the maximum position range of the MOST network. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Maximum position range of the network (MPR). + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetMPR(IABI* pAbi, BYTE& result); + + /// Get the mute state of the selected audio connector. + /// \param[in] pAbi Used IABI instance. + /// \param[in] connector The selected audio connector type. + /// \param[in] isInput true if input connector should be modified, otherwise output connector is modified. + /// \param[out] result true if channel is muted, otherwise false. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetMuteState(IABI* pAbi, AudioConnectorType connector, bool isInput, bool& result); + + /// Gets the MAC address of device. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result MAC address of device. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int GetNetMask(IABI* pAbi, char*& result); + + /// Gets the MOST node position of device. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Node position of device (NPR). + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int GetNPR(IABI* pAbi, BYTE& result); + + /// Retrieves a value by a given key. + /// \param[in] pAbi Used IABI instance. + /// \param[in] key Selected key. + /// \param[out] result Value of selected key. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup EXT + static int GetParameter(IABI* pAbi, char* key, char*& result); + + /// Retrieves all available keys as comma separated string. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result All available keys. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup EXT + static int GetParameterKeys(IABI* pAbi, char*& result); + + /// Retrieves all available values as comma separated string by a given key. + /// \param[in] pAbi Used IABI instance. + /// \param[in] key Selected key. + /// \param[out] result All available values. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup EXT + static int GetParameterValues(IABI* pAbi, char* key, char*& result); + + /// Gets the running time of the device. The time is represented in steps of 100 nanoseconds. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Time that passed since starting the device. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int GetRunningTime(IABI* pAbi, unsigned long long& result); + + /// Gets the serial number of the device. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result result Serial number of device. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int GetSerialNumber(IABI* pAbi, char*& result); + + /// Gets the actual timestamp. The timestamp is represented in steps of 100 nanoseconds. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Actual timestamp. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int GetTimeStamp(IABI* pAbi, unsigned long long& result); + + /// Get the mode of the hardware synchronisation unit. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Actual mode of hardware synchronisation unit. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int GetTimingSynchronisationMode(IABI* pAbi, TimingSynchronisationMode& result); + + /// Gets the voltage level of trigger line. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result TRUE means active (voltage low), FALSE means inactive (voltage high). + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int GetTriggerLevel(IABI* pAbi, bool& result); + + /// Determinates if the streaming module provides an allocation table. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result TRUE if supported, FALSE otherwise. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int HasAllocationTableSupport(IABI* pAbi, bool& result); + + /// Determinates if the streaming module provides support to stream the input to multiple labels. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result TRUE if supported, FALSE otherwise. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int HasMultipleStreamInSupport(IABI* pAbi, bool& result); + + /// Determinates if the streaming module provides support to stream the own input signal to the out connector. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result TRUE if supported, FALSE otherwise. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int HasRedirectStreamInToOutSupport(IABI* pAbi, bool& result); + + /// Identifies a device by toggling hectically the active LED for a few seconds. + /// \param[in] pAbi Used IABI instance. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int Identify(IABI* pAbi); + + /// Determinates if the selected bus is started. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Selected channel. + /// \param[out] result Running state, TRUE if the selected bus is started, FALSE otherwise. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int IsBusStarted(IABI* pAbi, Bus bus, bool& result); + + /// Check if the desired CAN transceiver type is supported by the hardware. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus CAN channel. + /// \param[in] transceiver Type that should be checked. + /// \param[out] result TRUE if supported, FALSE if not. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup CAN + static int IsCanTransceiverSupported(IABI* pAbi, Bus bus, CanTransceiver transceiver, bool& result); + + /// Determinates if the choosen FlexRay bus is in a synchronized state. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Selected FlexRay channel. + /// \param[out] result Synchron State, TRUE if synchronized. False if not the bus is not synchronized. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup FR + static int IsFlexRaySynchronized(IABI* pAbi, Bus bus, bool& result); + + /// Retrieves if FlexRay tx messages are enabled. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result TRUE if FlexRay tx messages are enabled, otherwise FALSE. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup FR + static int IsFlexRayTxEnabled(IABI* pAbi, bool& result); + + /// Determinates if the choosen LIN bus is configured to act as Master. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Selected LIN channel. + /// \param[out] result Master state, TRUE if acting as Master, FALSE if acting as Slave. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup LIN + static int IsLinMaster(IABI* pAbi, Bus bus, bool& result); + + /// Checks if the MEP<->Ethernet Bridge is activated. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result TRUE if bridge is activated otherwise FALSE. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note Only available for MOST 150. + /// \ingroup MOST + static int IsMepEthernetBridgeEnabled(IABI* pAbi, bool& result); + + /// Retrieves if MOST node (INIC) is supported. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result TRUE means device supports a MOST node and FALSE means not. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int IsMostNodeSupported(IABI* pAbi, bool& result); + + /// Retrieves if MOST spy (SpyNIC) is supported. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result TRUE means device supports a MOST spy and FALSE means not. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int IsMostSpySupported(IABI* pAbi, bool& result); + + /// Retrieves if MOST stress (StressNIC) is supported. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result TRUE means device supports a MOST stress and FALSE means not. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int IsMostStressSupported(IABI* pAbi, bool& result); + + /// Determinates if the MOST bus is in state Net On. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Net On state, TRUE if the Most bus is in state Net On, FALSE otherwise. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int IsNetOn(IABI* pAbi, bool& result); + + /// Gets the state of the relay. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result State of relay. TRUE means close and FALSE means open. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int IsRelayClosed(IABI* pAbi, bool& result); + + /// Determinates if the MOST bus is in state Stable Lock. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Stable Lock state, TRUE if the Most bus is in state Stable Lock, FALSE otherwise. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int IsStableLock(IABI* pAbi, bool& result); + + /// Checks if transmission of payload in tx events is filtered. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Bus that is selected for this command. + /// \param[out] result FALSE if tx events have payload otherwise TRUE. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int IsTxPayloadFilterEnabled(IABI* pAbi, Bus bus, bool& result); + + /// Allocate a new audio streaming channel. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bandwidth Desired bandwidth of the allocated audio channel. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note This command is asynchronous. + /// \attention Will be removed in further versions. Use MostAudioTxAllocateConnect or MostAudioTxAllocateConnectSync instead. + /// \ingroup MOST + static int MostAudioAllocate(IABI* pAbi, AudioBandwidth bandwidth); + + /// Stream an audio stream from the MOST ring to the out connectors of the MOCCA compact. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bandwidth Desired bandwidth of the audio channel. + /// \param[in] label Label that is used. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note This command is asynchronous. + /// \ingroup MOST + static int MostAudioRxConnect(IABI* pAbi, AudioBandwidth bandwidth, unsigned int label); + + /// Stream an audio stream from the MOST ring to the out connectors of the MOCCA compact. If the SPDIF connector is already used for another label it is disconnected and connected to the given label. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bandwidth Desired bandwidth of the audio channel. + /// \param[in] label Label that is used. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note If no label is used before it acts like MostAudioRxConnect. + /// \note This command is asynchronous. + /// \ingroup MOST + static int MostAudioRxConnectExt(IABI* pAbi, AudioBandwidth bandwidth, unsigned int label); + + /// Disconnect the audio streaming to the out connectors. + /// \param[in] pAbi Used IABI instance. + /// \param[in] label Label that is used. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note This command is asynchronous. + /// \ingroup MOST + static int MostAudioRxDisconnect(IABI* pAbi, unsigned int label); + + /// Allocate a new audio streaming channel and stream the SPDIF in connector of the MOCCA compact to the MOST ring. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bandwidth Desired bandwidth of the allocated audio channel. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note This command is asynchronous. + /// \ingroup MOST + static int MostAudioTxAllocateConnect(IABI* pAbi, AudioBandwidth bandwidth); + + /// Allocate a new audio streaming channel and stream the selected IN connector of the MOCCA compact to the MOST ring. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bandwidth Desired bandwidth of the allocated audio channel. + /// \param[in] connector The connector that should be used. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note This command is asynchronous. + /// \ingroup MOST + static int MostAudioTxAllocateConnect(IABI* pAbi, AudioBandwidth bandwidth, AudioConnectorType connector); + + /// Stream the SPDIF input connector of the MOCCA compact to the MOST ring on a preallocated label. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bandwidth Desired bandwidth of the allocated audio channel. + /// \param[in] label Label that is used. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note This command is asynchronous. + /// \attention Will be removed in further versions. Use MostAudioTxAllocateConnect or MostAudioTxAllocateConnectSync instead. + /// \ingroup MOST + static int MostAudioTxConnect(IABI* pAbi, AudioBandwidth bandwidth, unsigned int label); + + /// Disconnect the audio streaming from SPDIF input from channel. + /// \param[in] pAbi Used IABI instance. + /// \param[in] label Label that is used. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note This command is asynchronous. + /// \ingroup MOST + static int MostAudioTxDisconnect(IABI* pAbi, unsigned int label); + + /// Reboots the device. + /// \param[in] pAbi Used IABI instance. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int RebootFirmware(IABI* pAbi); + + /// Reset the shutdown reason of INIC. + /// \param[in] pAbi Used IABI instance. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note Only available for MOST 150. + /// \ingroup MOST + static int ResetMostShutdownReason(IABI* pAbi); + + /// Resets timestamp unit of device. + /// \param[in] pAbi Used IABI instance. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note This command is only working if the timestamp synchronisation is set to standalone. This command will be ignored, if timestamp synchronisation is set to master os slave mode. + /// \ingroup HW + static int ResetTimeStamp(IABI* pAbi); + + /// Selects active group. + /// \param[in] pAbi Used IABI instance. + /// \param[in] group Selected group. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int SelectGroup(IABI* pAbi, BYTE group); + + /// Send a message via CAN Transport Protocol. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of tx message. + /// \param[in] bus Transmitting bus. + /// \param[in] source Source address. + /// \param[in] destination Destination address. + /// \param[in] type TP addressing type. + /// \param[in] payloadLength Length of payload. + /// \param[in] payload Payload data. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note The maximum length of message is 4095 bytes. + /// \ingroup CANTP + static int SendCanTpMessage(IABI* pAbi, unsigned short handle, Bus bus, unsigned int source, unsigned int destination, TPAddressingType type, unsigned short payloadLength, BYTE* payload); + + /// Send a message immediately to the selected bus. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of tx message. + /// \param[in] bus Transmitting bus. + /// \param[in] targetAddress Target address. + /// \param[in] messageId Message identifier. + /// \param[in] payloadLength Length of payload. + /// \param[in] payload Payload data. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note MessageID CAN: CanId + /// \note MessageID FlexRay: (CycleRepetition - 1) << 24 | CycleOffset << 16 | FlexrayLogicalChannel << 12 | FrameId + /// \note MessageID LIN: LinId + /// \note MessageID MOST: FBlockId << 24 | (InstanceId & 0xFF) << 16) | (FunctionId & 0xFFF) << 4 | OpTypeId & 0x0F + /// \note There are bus specific send commands for every field bus, which takes the needed parameters directly, so no transformation is needed. + /// \ingroup OBJ + static int SendMessage(IABI* pAbi, unsigned short handle, Bus bus, unsigned short targetAddress, unsigned int messageId, unsigned short payloadLength, BYTE* payload); + + /// Send a message immediately to MOST asynchronous channel with MOST HIGH protocol using MOST High. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of tx message. + /// \param[in] targetAddress Target address. + /// \param[in] fblockID FBlock identifier. + /// \param[in] instanceID Instance identifier. + /// \param[in] functionID Function identifier. + /// \param[in] opType Operation type. + /// \param[in] minDelay Minimum delay for speed regulation. + /// \param[in] maxDelay Maximum delay for speed regulation. + /// \param[in] priority Priority value used for this message. + /// \param[in] options Options for the transmission. + /// \param[in] totalPacketLength Length of complete package. + /// \param[in] payloadLength Length of payload. + /// \param[in] payload Payload data. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note This function is only for usage of MOST High bigger than 64kByte. + /// \note The maximum length of message is 65535 bytes. + /// \ingroup MOST + static int SendMostHighExtendedMessage(IABI* pAbi, unsigned short handle, unsigned short targetAddress, BYTE fblockID, BYTE instanceID, unsigned short functionID, BYTE opType, unsigned short minDelay, unsigned short maxDelay, BYTE priority, MostMhpOptions options, unsigned int totalPacketLength, unsigned short payloadLength, BYTE* payload); + + /// Send a message immediately to MOST asynchronous channel with MOST HIGH protocol using MOST High bigger 64kByte. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of tx message. + /// \param[in] targetAddress Target address. + /// \param[in] fblockID FBlock identifier. + /// \param[in] instanceID Instance identifier. + /// \param[in] functionID Function identifier. + /// \param[in] opType Operation type. + /// \param[in] totalPacketLength Length of complete package. + /// \param[in] payloadLength Length of payload. + /// \param[in] payload Payload data. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note This function is only for usage of MOST High bigger than 64kByte. + /// \note The maximum length of message is 65535 bytes. + /// \ingroup MOST + static int SendMostHighExtMessage(IABI* pAbi, unsigned short handle, unsigned short targetAddress, BYTE fblockID, BYTE instanceID, unsigned short functionID, BYTE opType, unsigned int totalPacketLength, unsigned short payloadLength, BYTE* payload); + + /// Sends a message over MOST MEP. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of tx message. + /// \param[in] retryCount Retry count of tx message. + /// \param[in] priority Priority of tx message. + /// \param[in] payload Message to be send. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note Only available for MOST 150. + /// \note The message have to be a valid ethernet package. + /// \ingroup MOST + static int SendMostMepExtMessage(IABI* pAbi, unsigned short handle, BYTE retryCount, BYTE priority, unsigned short payloadLength, BYTE* payload); + + /// Sends a message over MOST MEP. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of tx message. + /// \param[in] payload Message to be send. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note Only available for MOST 150. + /// \note The message have to be a valid ethernet package. + /// \ingroup MOST + static int SendMostMepMessage(IABI* pAbi, unsigned short handle, unsigned short payloadLength, BYTE* payload); + + /// Sets the boundary of the MOST bus. + /// \param[in] pAbi Used IABI instance. + /// \param[in] boundary New boundary value (SBC). + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int SetBoundary(IABI* pAbi, BYTE boundary); + + /// Sets CAN TP pattern to fill CAN telegrams up to 8 bytes. + /// \param[in] pAbi Used IABI instance. + /// \param[in] pattern Content of fill bytes. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup CANTP + static int SetCanTpPattern(IABI* pAbi, BYTE pattern); + + /// Initializes global parameters for CAN TP Rx. + /// \param[in] pAbi Used IABI instance. + /// \param[in] blockSize Flow Control block size. + /// \param[in] separationTime Minimum time gap between the transmission of CF. + /// \param[in] consecutiveFrameTimeout Timeout for the next consecutive frame. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup CANTP + static int SetCanTpRxConfig(IABI* pAbi, BYTE blockSize, BYTE separationTime, unsigned short consecutiveFrameTimeout); + + /// Initializes global parameters for CAN TP Tx. + /// \param[in] pAbi Used IABI instance. + /// \param[in] flowControlTimeout Defines timeout interval for flow control. + /// \param[in] clearToSendTimeout Defines minimum time between two tx messages. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup CANTP + static int SetCanTpTxConfig(IABI* pAbi, unsigned short flowControlTimeout, unsigned short clearToSendTimeout); + + /// Set the device mode of the INIC. The network is not started. + /// \param[in] pAbi Used IABI instance. + /// \param[in] deviceMode Device mode that is used. + /// \param[in] options Options that are attended at startup (See DeviceModeOptions). + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note Multiple options can be combined. + /// \ingroup MOST + static int SetDeviceMode(IABI* pAbi, MostMode deviceMode, DeviceModeOptions options); + + /// Sets the MOST group address address of device. + /// \param[in] pAbi Used IABI instance. + /// \param[in] groupAddress New group address of device. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int SetGroupAddr(IABI* pAbi, unsigned short groupAddress); + + /// Sets the logical MOST node address of device. + /// \param[in] pAbi Used IABI instance. + /// \param[in] nodeAddress New logical node address of device. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int SetLogicalNodeAddr(IABI* pAbi, unsigned short nodeAddress); + + /// Set the count of high level retries. These retries are visible on Spy and Node (TNAK). + /// \param[in] pAbi Used IABI instance. + /// \param[in] retryCount Count of high level retries. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int SetMostControlChannelHighLevelRetry(IABI* pAbi, BYTE retryCount); + + /// Set the count of low level retries. These retries are only visible on Spy. + /// \param[in] pAbi Used IABI instance. + /// \param[in] retryCount Count of low level retries. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int SetMostControlChannelLowLevelRetry(IABI* pAbi, BYTE retryCount); + + /// Set the count of mid level retries. These retries are only visible on Spy. + /// \param[in] pAbi Used IABI instance. + /// \param[in] retryCount Count of mid level retries. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int SetMostControlChannelMidLevelRetry(IABI* pAbi, BYTE retryCount); + + /// Set the frequency of MOST. + /// \param[in] pAbi Used IABI instance. + /// \param[in] frequency Frequency of MOST. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note Only available for MOST 25 and MOST 50. + /// \ingroup MOST + static int SetMostFrequency(IABI* pAbi, MostSamplingFrequency frequency); + + /// Set the MOST illumination level. + /// \param[in] pAbi Used IABI instance. + /// \param[in] level MOST illumination level. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int SetMostIlluminationLevel(IABI* pAbi, MostIlluminationLevel level); + + /// Set MAC address of MOST node. + /// \param[in] pAbi Used IABI instance. + /// \param[in] macAddress MAC address that should be set in MOST node. + /// \param[in] isPersistent TRUE if MAC address should be available after reset otherwise FALSE. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note Only available for MOST 150. + /// \ingroup MOST + static int SetMostMacAddress(IABI* pAbi, unsigned long long macAddress, bool isPersistent); + + /// Set the mute state of the selected audio connector. + /// \param[in] pAbi Used IABI instance. + /// \param[in] connector The selected audio connector type. + /// \param[in] isInput true if input connector should be modified, otherwise output connector is modified. + /// \param[in] mute Mute if true, otherwise unmute. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int SetMuteState(IABI* pAbi, AudioConnectorType connector, bool isInput, bool mute); + + /// Sets a software or hardware property by a given key/value pair. + /// \param[in] pAbi Used IABI instance. + /// \param[in] key Selected key. + /// \param[in] newValue Value that should be set. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup EXT + static int SetParameter(IABI* pAbi, char* key, char* newValue); + + /// Sets the state of the relay. + /// \param[in] pAbi Used IABI instance. + /// \param[in] switchOn State of relay. TRUE means close and FALSE means open. + /// \param[out] result Timestamp of action. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int SetRelay(IABI* pAbi, bool switchOn, unsigned long long& result); + + /// Sets the actual timestamp. The timestamp is represented in steps of 100 nanoseconds. + /// \param[in] pAbi Used IABI instance. + /// \param[in] Actual timestamp. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int SetTimeStamp(IABI* pAbi, unsigned long long timestamp); + + /// Set the mode of the hardware synchronisation unit. + /// \param[in] pAbi Used IABI instance. + /// \param[in] mode Timing mode of hardware synchronisation unit. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int SetTimingSynchronisationMode(IABI* pAbi, TimingSynchronisationMode mode); + + /// Sets the voltage level of trigger line. + /// \param[in] pAbi Used IABI instance. + /// \param[in] isActive TRUE means active (voltage low), FALSE means inactive (voltage high). + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup HW + static int SetTriggerLevel(IABI* pAbi, bool isActive); + + /// Enables/Disables transmission of payload in tx events. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Bus that is selected for this command. + /// \param[in] isEnabled TRUE if payload is not transmitted on tx events otherwise FALSE. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int SetTxPayloadFilter(IABI* pAbi, Bus bus, bool isEnabled); + + /// Set the volume of the selected audio connector. + /// \param[in] pAbi Used IABI instance. + /// \param[in] connector The selected audio connector type. + /// \param[in] isInput true if input connector should be modified, otherwise output connector is modified. + /// \param[in] modifyLeft Modify left channel. + /// \param[in] modifyRight Modify right channel. + /// \param[in] volume Attenuation(-)/Gain(+) in db. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int SetVolume(IABI* pAbi, AudioConnectorType connector, bool isInput, bool modifyLeft, bool modifyRight, int volume); + + /// Shutdown the MOST network. The INIC is staying in the current mode. + /// \param[in] pAbi Used IABI instance. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note This function could only be called if the device is in a master mode. + /// \ingroup MOST + static int ShutdownMost(IABI* pAbi); + + /// Starts test or one transmitting or receiving rule. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of object you want to start. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int Start(IABI* pAbi, unsigned short handle); + + /// Starts the CAN channel with selected transceiver type and baud rate. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Selected channel. + /// \param[in] transceiverType Selected transceiver type. + /// \param[in] speed Selected baud rate. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup CAN + static int StartCan(IABI* pAbi, Bus bus, CanTransceiver transceiverType, CanSpeed speed); + + /// Starts the CAN channel with selected transceiver type and with individual baud rate. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Selected channel. + /// \param[in] transceiverType Selected transceiver type. + /// \param[in] brp Prescaler value to divide base frequency. + /// \param[in] tseg1 Time segment 1 value. + /// \param[in] tseg2 Time segment 2 value. + /// \param[in] sjw Synchronization jump width. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note The base frequency for MOCCA compact 2.x is for CAN1-4: 16MHz, CAN5-6: 25MHz. For MOCCA compact 3.x all CANs have the base frequency 16Mhz. + /// \ingroup CAN + static int StartCanExt(IABI* pAbi, Bus bus, CanTransceiver transceiverType, BYTE brp, BYTE tseg1, BYTE tseg2, BYTE sjw); + + /// Starts the FlexRay channel with an individual configuration file. + /// \param[in] pAbi Used IABI instance. + /// \param[in] blob Configuration file. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup FR + static int StartFlexRay(IABI* pAbi, unsigned short payloadLength, BYTE* blob); + + /// Starts the Lin channel with an individual configuration file. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Selected channel. + /// \param[in] blob Configuration file. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note A LIN channel can only be used as node or spy! + /// \ingroup LIN + static int StartLin(IABI* pAbi, Bus bus, unsigned short payloadLength, BYTE* blob); + + /// Starts LIN Spy channel. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Selected channel. + /// \param[in] baudrate Baudrate that runs in the LIN master. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note A LIN channel can only be used as node or spy! + /// \ingroup LIN + static int StartLinSpy(IABI* pAbi, Bus bus, unsigned int baudrate); + + /// Starts the MOST channel. + /// \param[in] pAbi Used IABI instance. + /// \param[in] mode Selected MOST mode. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int StartMost(IABI* pAbi, MostMode mode); + + /// Startup the network with the preselected device mode. + /// \param[in] pAbi Used IABI instance. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note In case of slave mode a wakeup is done. + /// \note A bypass could not make a startup. + /// \ingroup MOST + static int StartupMost(IABI* pAbi); + + /// Stops test or one transmitting or receiving rule. + /// \param[in] pAbi Used IABI instance. + /// \param[in] handle Handle of object you want to stop. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup OBJ + static int Stop(IABI* pAbi, unsigned short handle); + + /// Stops the CAN channel. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Selected channel. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup CAN + static int StopCan(IABI* pAbi, Bus bus); + + /// Stops the FlexRay channel. + /// \param[in] pAbi Used IABI instance. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup FR + static int StopFlexRay(IABI* pAbi); + + /// Stops the LIN channel. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Selected channel. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note A LIN channel can only be used as node or spy! + /// \ingroup LIN + static int StopLin(IABI* pAbi, Bus bus); + + /// Stops LIN Spy channel. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Selected channel. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note A LIN channel can only be used as node or spy! + /// \ingroup LIN + static int StopLinSpy(IABI* pAbi, Bus bus); + + /// Stops the MOST channel. + /// \param[in] pAbi Used IABI instance. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int StopMost(IABI* pAbi); + + /// Gets the device mode of StressNIC. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Device mode. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int StressNicDeviceModeGet(IABI* pAbi, StressNicMode& result); + + /// Sets the device mode of StressNIC. + /// \param[in] pAbi Used IABI instance. + /// \param[in] mode Device mode. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int StressNicDeviceModeSet(IABI* pAbi, StressNicMode mode); + + /// Sends a set command to the StressNIC. + /// \param[in] pAbi Used IABI instance. + /// \param[in] fblockId FBlock identifier of command. + /// \param[in] functionId Function identifier of command. + /// \param[in] payload Payload of function. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int StressNicFunctionSet(IABI* pAbi, BYTE fblockId, unsigned short functionId, unsigned short payloadLength, BYTE* payload); + + /// Gets the group address of StressNIC. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Group address. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int StressNicGroupAddressGet(IABI* pAbi, unsigned short& result); + + /// Sets the group address of StressNIC. + /// \param[in] pAbi Used IABI instance. + /// \param[in] groupAddress Group address. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int StressNicGroupAddressSet(IABI* pAbi, unsigned short groupAddress); + + /// Gets the node address of StressNIC. + /// \param[in] pAbi Used IABI instance. + /// \param[out] result Node address. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int StressNicNodeAddressGet(IABI* pAbi, unsigned short& result); + + /// Sets the node address of StressNIC. + /// \param[in] pAbi Used IABI instance. + /// \param[in] nodeAddress Node address. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int StressNicNodeAddressSet(IABI* pAbi, unsigned short nodeAddress); + + /// Sends a message from the StressNic. + /// \param[in] pAbi Used IABI instance. + /// \param[in] deviceId Target device id. + /// \param[in] fblockId FBlock id. + /// \param[in] instance Instance id. + /// \param[in] functionId Function identifier of command. + /// \param[in] opType Operation type. + /// \param[in] payload Payload of function. + /// \param[out] result There is no indication if the message has been send successful or not. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int StressNicSendMessage(IABI* pAbi, unsigned short deviceId, BYTE fblockId, BYTE instance, unsigned short functionId, BYTE opType, unsigned short payloadLength, BYTE* payload); + + /// Switches the device into bypass mode so that is not participating in MOST network. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bypassMode Selected mode. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \ingroup MOST + static int SwitchBypassMode(IABI* pAbi, BypassMode bypassMode); + + /// Writes a binary startup configuration in to the EEPROM of the device. This configuration will be executed every time the device is powered on. + /// \param[in] pAbi Used IABI instance. + /// \param[in] bus Bus which the startup configuration belongs to. + /// \param[in] configuration Bus configuration as binary stream. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + /// \note Configuration FlexRay: Binary output from the K2L FlexRay Toolchain. + /// \note Configuration LIN: Binary output from the K2L LIN Toolchain. + /// \ingroup HW + static int WriteBusConfiguration(IABI* pAbi, Bus bus, unsigned short payloadLength, BYTE* configuration); + + +}; + } + } +} +//@} +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// END OF FILE +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/K2LABI/ABI/ABIFilter.cpp b/K2LABI/ABI/ABIFilter.cpp new file mode 100644 index 0000000..806e06e --- /dev/null +++ b/K2LABI/ABI/ABIFilter.cpp @@ -0,0 +1,190 @@ +#include "ABIFilter.h" + +CABIFilter::CABIFilter() +{ + for(int index = 0; index < 256; index++) + { + m_filters[index] = NULL; + } +} + +//----------------------------------------------------------------------------- + +CABIFilter::~CABIFilter() +{ + for(int index = 0; index < 256; index++) + { + if(m_filters[index] != NULL) + { + delete m_filters[index]; + m_filters[index] = NULL; + } + } +} + +//----------------------------------------------------------------------------- + +void CABIFilter::AddIntervalFilter(Bus bus, unsigned short handle, unsigned int min, unsigned int max) +{ + int index = (int) bus; + if (m_filters[index] == NULL) + { + m_filters[index] = new CIdFilter(); + } + m_filters[index]->AddIntervalFilter(handle, min, max); +} + +//----------------------------------------------------------------------------- + +void CABIFilter::AddMaskedFilter(Bus bus, unsigned short handle, unsigned int id, unsigned int mask) +{ + int index = (int)bus; + if (m_filters[index] == NULL) + { + m_filters[index] = new CIdFilter(); + } + m_filters[index]->AddMaskedFilter(handle, id, mask); +} + +//----------------------------------------------------------------------------- + +void CABIFilter::RemoveFilter(unsigned short handle) +{ + for (int index = 0; index < 256; index++) + { + if (m_filters[index] != NULL) + { + m_filters[index]->RemoveFilter(handle); + } + } +} + +//----------------------------------------------------------------------------- + +bool CABIFilter::Match(Bus bus, unsigned int id) +{ + int index = (int)bus; + CIdFilter* filter = m_filters[index]; + if (filter == NULL) + { + //if no filters are added all messages will be delivered. + return true; + } + return filter->Match(id); +} + +//----------------------------------------------------------------------------- + +IntervalIdFilterEntry::IntervalIdFilterEntry(unsigned short handle, unsigned int min, unsigned int max) : +m_handle(handle), +m_min(min), +m_max(max) +{ +} + +unsigned short IntervalIdFilterEntry::Handle() +{ + return m_handle; +} + +//----------------------------------------------------------------------------- + +bool IntervalIdFilterEntry::Match(unsigned int id) +{ + return ((m_min <= id) && (id <= m_max)); +} + +//----------------------------------------------------------------------------- + +MaskedIdFilterEntry::MaskedIdFilterEntry(unsigned short handle, unsigned int id, unsigned int mask) : + m_handle(handle), + m_id(id), + m_mask(mask) +{ +} + +//----------------------------------------------------------------------------- + +unsigned short MaskedIdFilterEntry::Handle() +{ + return m_handle; +} + +//----------------------------------------------------------------------------- + +bool MaskedIdFilterEntry::Match(unsigned int id) +{ + return ((id & m_mask) == (m_id & m_mask)); +} + +//----------------------------------------------------------------------------- + +CIdFilter::CIdFilter() : +m_filters() +{ + ::InitializeCriticalSection(&m_criticalSection); +} + +//----------------------------------------------------------------------------- + +CIdFilter::~CIdFilter() +{ + ::DeleteCriticalSection(&m_criticalSection); +} + +//----------------------------------------------------------------------------- + +void CIdFilter::AddIntervalFilter(unsigned short handle, unsigned int min, unsigned int max) +{ + IntervalIdFilterEntry* filter = new IntervalIdFilterEntry(handle, min, max); + m_filters.push_back(filter); +} + +//----------------------------------------------------------------------------- + +void CIdFilter::AddMaskedFilter(unsigned short handle, unsigned int id, unsigned int mask) +{ + MaskedIdFilterEntry* filter = new MaskedIdFilterEntry(handle, id, mask); + m_filters.push_back(filter); +} + +//----------------------------------------------------------------------------- + +void CIdFilter::RemoveFilter(unsigned short handle) +{ + ::EnterCriticalSection(&m_criticalSection); + for (unsigned int index = 0; index < m_filters.size(); index++) + { + IFilterEntry* filter = m_filters[index]; + if (filter->Handle() == handle) + { + m_filters.erase (m_filters.begin() + index); + delete filter; + break; + } + } + ::LeaveCriticalSection(&m_criticalSection); +} + +//----------------------------------------------------------------------------- + +bool CIdFilter::Match(unsigned int id) +{ + //TODO: PORT this unix ("for each" does not exist) +#if 0 + ::EnterCriticalSection(&m_criticalSection); + bool ret = false; + for each (IFilterEntry* filterEntry in m_filters) + { + if (filterEntry->Match(id)) + { + ret = true; + break; + } + } + ::LeaveCriticalSection(&m_criticalSection); + return ret; +#else + return true; +#endif +} diff --git a/K2LABI/ABI/ABIFilter.h b/K2LABI/ABI/ABIFilter.h new file mode 100644 index 0000000..ccdda8f --- /dev/null +++ b/K2LABI/ABI/ABIFilter.h @@ -0,0 +1,81 @@ +#pragma once + +#include "windows-adapter.h" +#include "K2LABI.h" +#include <vector> + +using namespace K2L::Automotive::ABI; + +class IFilterEntry +{ +public: + virtual ~IFilterEntry(){} + + virtual unsigned short Handle() = 0; + virtual bool Match(unsigned int id) = 0; +}; + +class IntervalIdFilterEntry : public IFilterEntry +{ +private: + IntervalIdFilterEntry(){} + + unsigned short m_handle; + unsigned int m_min; + unsigned int m_max; +public: + IntervalIdFilterEntry(unsigned short handle, unsigned int min, unsigned int max); + virtual ~IntervalIdFilterEntry(){} + + unsigned short Handle(); + bool Match(unsigned int id); +}; + +class MaskedIdFilterEntry : public IFilterEntry +{ +private: + MaskedIdFilterEntry(){} + + unsigned short m_handle; + unsigned int m_id; + unsigned int m_mask; +public: + MaskedIdFilterEntry(unsigned short handle, unsigned int id, unsigned int mask); + virtual ~MaskedIdFilterEntry(){} + + unsigned short Handle(); + bool Match(unsigned int id); +}; + +class CIdFilter +{ +private: + std::vector<IFilterEntry*> m_filters; + CRITICAL_SECTION m_criticalSection; + +public: + CIdFilter(); + virtual ~CIdFilter(); + + void AddIntervalFilter(unsigned short handle, unsigned int min, unsigned int max); + void AddMaskedFilter(unsigned short handle, unsigned int id, unsigned int mask); + void RemoveFilter(unsigned short handle); + + bool Match(unsigned int id); +}; + +class CABIFilter +{ +private: + CIdFilter* m_filters[256]; + +public: + CABIFilter(); + virtual ~CABIFilter(); + + void AddIntervalFilter(Bus bus, unsigned short handle, unsigned int min, unsigned int max); + void AddMaskedFilter(Bus bus, unsigned short handle, unsigned int id, unsigned int mask); + void RemoveFilter(unsigned short handle); + + bool Match(Bus bus, unsigned int id); +}; diff --git a/K2LABI/ABI/ABIFunctionDefinition.h b/K2LABI/ABI/ABIFunctionDefinition.h new file mode 100644 index 0000000..1aa96e6 --- /dev/null +++ b/K2LABI/ABI/ABIFunctionDefinition.h @@ -0,0 +1,254 @@ +#pragma once + +typedef enum +{ + TestMaster = 0x01, + Board = 0x02, + NetServices = 0x03, + StressNic = 0x04 +} Interfaces; + +typedef enum +{ + FunId__SelectGroup = 2, + + FunId__Start = 4, + + FunId__Stop = 6, + + FunId__Delete = 8, + + FunId__SetCanTpRxConfig = 10, + FunId__GetCanTpRxConfig = 11, + FunId__SetCanTpTxConfig = 12, + FunId__GetCanTpTxConfig = 13, + FunId__SetCanTpPattern = 14, + FunId__GetCanTpPattern = 15, + FunId__ClearCanTpPattern = 16, + + FunId__SendMessage = 20, + FunId__SendMostHighExtMessage = 21, + FunId__SendMostHighExtendedMessage = 22, + FunId__SendMostMepMessage = 23, + FunId__SendMostMepExtMessage = 24, + FunId__EnableMepEthernetBridge = 25, + FunId__IsMepEthernetBridgeEnabled = 26, + FunId__SendCanTpMessage = 27u, + FunId__EnableMepEthernetBridgeExtended = 28, + + FunId__AddCanTpTransmitter = 32, + + FunId__AddTxSweepSignal = 34, + FunId__DeleteTxSweepSignals = 35, + FunId__AddTransmitterEx = 36, + FunId__ChangeCycleTime = 37, + FunId__ChangeTransmitterData = 38, + + FunId__AddReceiver = 40, + + FunId__AddCanTpReceiver = 44, + + //FunId__AddLinReceiver = 46, //DEPRECATED + + FunId__WriteBusConfiguration = 50, + FunId__ReadBusConfiguration = 51, + //FunId__GetReceiverHandles = 52, //DEPRECATED + //FunId__GetTransmitterHandles = 53, //DEPRECATED + FunId__GetAllUsedHandles = 54, + FunId__GetInformationOfObject = 55, + + FunId__GetInternalState = 100, + FunId__SetTxPayloadFilter = 101, + FunId__IsTxPayloadFilterEnabled = 102 + + //TM__MIN_EVENT_ID = 128, //DEPRECATED + //EventId__OnTxMessage = TM__MIN_EVENT_ID + 1, //DEPRECATED + //EventId__OnRxMessage = TM__MIN_EVENT_ID + 2, //DEPRECATED + //EventId__OnTxNAK = TM__MIN_EVENT_ID + 4, //DEPRECATED + //EventId__OnTxFailed = TM__MIN_EVENT_ID + 5, //DEPRECATED + //EventId__OnCanTpTxMessage = TM__MIN_EVENT_ID + 6, //DEPRECATED + //EventId__OnCanTpRxMessage = TM__MIN_EVENT_ID + 7, //DEPRECATED + //EventId__OnBusEvent = TM__MIN_EVENT_ID + 8, //DEPRECATED + //EventId__OnInternalEvent = TM__MIN_EVENT_ID + 9, //DEPRECATED + //EventId__OnGeneralEvent = TM__MIN_EVENT_ID + 10,//DEPRECATED + //EventId__OnTxMessageExt = TM__MIN_EVENT_ID + 11, //DEPRECATED + //EventId__OnRxMessageExt = TM__MIN_EVENT_ID + 12 //DEPRECATED +} TestMasterFunctions; + +typedef enum +{ + FunId__GetFirmwareVersion = 0x01, + FunId__GetHardwareVersion = 0x03, + FunId__GetSerialNumber = 0x05, + FunId__GetRunningTime = 0x07, + FunId__RebootFirmware = 0x09, + FunId__SetRelay = 0x0B, + FunId__IsRelayClosed = 0x0C, + FunId__GetHardwareRevision = 0x0D, + + //FunId__SetCanSpeed = 0x0F,//DEPRECATED + + //FunId__ReInitCAN = 0x11,//DEPRECATED + + FunId__GetCurrentConfiguration = 0x13, + + FunId__FlashConfiguration = 0x15, + + FunId__ResetTimeStamp = 0x17, + + FunId__GetTimeStamp = 0x19, + + FunId__SetTimeStamp = 0x1A, + + FunId__Identify = 0x1B, + + FunId__StartFlexRay = 0x1D, + + FunId__StopFlexRay = 0x1F, + + FunId__GetIpAddress = 0x21, + + FunId__GetNetMask = 0x23, + + FunId__GetGwAddress = 0x25, + + FunId__SetIpAddress = 0x27, + + FunId__SetNetMask = 0x29, + + FunId__SetGwAddress = 0x2B, + + //FunId__SetCanTransceiver = 0x2F,//DEPRECATED + + FunId__StartLin = 0x31, + + FunId__StopLin = 0x33, + FunId__GetLinConfigurationName = 0x34, + FunId__GetInformation = 0x35, + FunId__SendCanRemoteFrame = 0x36, + FunId__StartCan = 0x37, + FunId__StartCanExt = 0x39, + + FunId__StopCan = 0x3B, + FunId__GetCanBaseFrequency = 0x3C, + FunId__GetExtendedBaudrate = 0x3D, + FunId__GetParameterKeys = 0x3E, + FunId__GetParameterValues = 0x3F, + FunId__GetParameter = 0x40, + FunId__SetParameter = 0x41, + FunId__GetCanTransceiver = 0x42, + FunId__GetCanSpeed = 0x43, + FunId__IsFlexRaySynchronized = 0x44, + FunId__IsLinMaster = 0x45, + FunId__GetLinSpeed = 0x46, + FunId__IsBusStarted = 0x47, + FunId__StartLinSpy = 0x48, + FunId__StopLinSpy = 0x49, + + FunId__SetTimingSynchronisationMode = 0x50, + FunId__GetTimingSynchronisationMode = 0x51, + FunId__IsCanTransceiverSupported = 0x52, + FunId__GetSupportedCanSpeeds = 0x53, + FunId__GetSupportedCanTransceivers = 0x54, + FunId__SendEchoCommand = 0x55, + FunId__GetLinBusCount = 0x56, + FunId__GetCanBusCount = 0x57, + FunId__GetFlexRayBusCount = 0x58, + FunId__EnableFlexRayTx = 0x59, + FunId__IsFlexRayTxEnabled = 0x5A, + + FunId__SendRelativeTriggerSequence = 0x60, + FunId__SendAbsoluteTriggerSequence = 0x61, + FunId__SetTriggerLevel = 0x62, + FunId__GetTriggerLevel = 0x63, + FunId__SetTimeout = 0x64, +} BoardFunctions; + +typedef enum +{ + FunId__GetLogicalNodeAddr = 0x07, + + FunId__StartMost = 0x09, + FunId__GetDeviceMode = 0x0A, + FunId__StopMost = 0x0B, + + FunId__SetLogicalNodeAddr = 0x0D, + FunId__GetMPR = 0x0E, + FunId__GetNPR = 0x0F, + + FunId__SwitchBypassMode = 0x11, + + FunId__SetGroupAddr = 0x13, + + FunId__GetGroupAddr = 0x15, + + FunId__SetBoundary = 0x17, + + FunId__GetBoundary = 0x19, + + FunId__IsNetOn = 0x30, + FunId__IsStableLock = 0x31, + FunId__SetMostIlluminationLevel = 0x32, + FunId__GetMostIlluminationLevel = 0x33, + FunId__HasAllocationTableSupport = 0x34, + FunId__HasMultipleStreamInSupport = 0x35, + FunId__HasRedirectStreamInToOutSupport = 0x36, + + FunId__MostAudioAllocate = 0x40, + FunId__MostAudioTxAllocateConnect = 0x41, + FunId__MostAudioTxConnect = 0x42, + FunId__MostAudioTxDisconnect = 0x43, + FunId__MostAudioRxConnect = 0x44, + FunId__MostAudioRxDisconnect = 0x45, + FunId__MostAudioRxConnectExt = 0x46, + FunId__MostAudioTxAllocateConnectSync = 0x47, + FunId__MostAudioTxDisconnectSync = 0x48, + FunId__MostAudioRxConnectSync = 0x49, + FunId__MostAudioRxDisconnectSync = 0x4A, + FunId__GetMostAudioSupportedTxConnectors = 0x4B, + FunId__SetVolume = 0x4C, + FunId__GetVolume = 0x4D, + FunId__GetSupportedVolumeRange = 0x4E, + + FunId__SetDeviceMode = 0x50, + FunId__StartupMost = 0x51, + FunId__ShutdownMost = 0x52, + FunId__SetMostControlChannelLowLevelRetry = 0x53, + FunId__GetMostControlChannelLowLevelRetry = 0x54, + FunId__SetMostControlChannelMidLevelRetry = 0x55, + FunId__GetMostControlChannelMidLevelRetry = 0x56, + FunId__SetMostControlChannelHighLevelRetry = 0x57, + FunId__GetMostControlChannelHighLevelRetry = 0x58, + FunId__SetMostFrequency = 0x59, + FunId__GetMostFrequency = 0x5A, + FunId__GetMostAllocationTable = 0x5B, + FunId__GetMostAudioRxLabels = 0x5C, + FunId__GetMostAudioTxLabels = 0x5D, + FunId__SetMostMacAddress = 0x5E, + FunId__GetMostMacAddress = 0x5F, + FunId__IsMostNodeSupported = 0x60, + FunId__IsMostSpySupported = 0x61, + FunId__IsMostStressSupported = 0x62, + FunId__GetMostSpeedGrade = 0x63, + + FunId__EnableMostSpy = 0x70, + FunId__MostSpyEnabled = 0x71, + FunId__GetMostShutdownReason = 0x72, + FunId__ResetMostShutdownReason = 0x73, + FunId__GetMuteState = 0x74, + FunId__SetMuteState = 0x75, +} NetServicesFunctions; + +typedef enum +{ + FunId__StressNicDeviceModeSet = 1, + FunId__StressNicDeviceModeGet = 2, + FunId__StressNicNodeAddressSet = 3, + FunId__StressNicNodeAddressGet = 4, + FunId__StressNicGroupAddressSet = 5, + FunId__StressNicGroupAddressGet = 6, + FunId__StressNicFunctionSet = 7, + FunId__StressNicFunctionGet = 8, + FunId__StressNicFunctionGetExtended = 9, + FunId__StressNicSendMessage = 10 +} StressNicFunctions;
\ No newline at end of file diff --git a/K2LABI/ABI/Ipc.cpp b/K2LABI/ABI/Ipc.cpp new file mode 100644 index 0000000..b19868e --- /dev/null +++ b/K2LABI/ABI/Ipc.cpp @@ -0,0 +1,181 @@ +#include "k2l-type.h" +#include "K2LIPC.h" +#include "IPCFlowDecoder.h" +#include "Ipc.h" +#include <string.h> + +//----------------------------------------------------------------------------- +class CIpcListener : public IIPCListener +{ +public: + CIpcListener() : messageCallback(0) + , errorCallback(0) + , messageLostCallback(0) + { + } + + virtual ~CIpcListener() {} + + virtual void OnMessage(IIpc* pIpc, BYTE channel, BYTE errorCode, BYTE* pPacket, int nLen) + { + if (messageCallback) + { + messageCallback(pIpc, channel, errorCode, pPacket, nLen); + } + } + + virtual void OnError(IIpc* pIpc) + { + if (errorCallback) + { + errorCallback(pIpc); + } + } + + virtual void OnMessageLost(IIpc* pIpc) + { + if (messageLostCallback) + { + messageLostCallback(pIpc); + } + } + + FCT_OnMessageEvent messageCallback; + FCT_OnEvent errorCallback; + FCT_OnEvent messageLostCallback; +}; + +//----------------------------------------------------------------------------- +CIpc::CIpc() : m_pResultBuffer(0) + , m_nResultLen(0) + , m_pIpcListener(0) + , m_pFlowDecoder(NULL) +{ +} + +//----------------------------------------------------------------------------- +CIpc::~CIpc() +{ +} + +//----------------------------------------------------------------------------- +IIPCListener* CIpc::GetListener() +{ + return m_pIpcListener; +} + +//----------------------------------------------------------------------------- +int CIpc::Init(IIPCListener* pListener) +{ + CSafeLock safeLock(&m_lock); + + m_pFlowDecoder = new CIPCFlowDecoder(this); + m_pIpcListener = pListener; + + return 0; +} + +//----------------------------------------------------------------------------- +int CIpc::Deinit() +{ + CSafeLock safeLock(&m_lock); + + m_pIpcListener = NULL; + delete m_pFlowDecoder; + m_pFlowDecoder = NULL; + + return 0; +} + +//----------------------------------------------------------------------------- +void CIpc::Decode(BYTE* pBuffer, DWORD nLen) +{ + CSafeLock safeLock(&m_lock); + + if (m_pFlowDecoder) + m_pFlowDecoder->DecodeFlow(pBuffer, nLen); +} + +//----------------------------------------------------------------------------- +int CIpc::FormatRequest(BYTE channel, BYTE ifaceId, BYTE funId, DWORD dwSenderID, const BYTE *pData, DWORD dataLen, BYTE* pResult, int nResultLen, int* nResultLenNeeded) +{ + int nRet = -1; + + if (!nResultLenNeeded) + return -1; + + *nResultLenNeeded = 0; + int nTotalLength = sizeof(CIpcPacket) + sizeof(CRequest) + dataLen; + + if (nTotalLength <= nResultLen) + { + if ((dataLen & 1) == 0 && pResult) + { + BYTE* buffer = pResult; + memset(buffer, 0, nTotalLength); + CIpcPacket* pIpcPacket = reinterpret_cast<CIpcPacket*>(buffer); + CRequest* pRequest = reinterpret_cast<CRequest*>(pIpcPacket + 1); + + pIpcPacket->m_head = 0x04; + pIpcPacket->m_channel = channel; + + pIpcPacket->m_length = sizeof(CRequest) + dataLen; + + pRequest->m_interface = ifaceId; + pRequest->m_function = funId; + + if (pData != NULL && dataLen > 0) + { + memcpy(reinterpret_cast<BYTE*>(pRequest + 1), pData, dataLen); + } + + pRequest->m_requestId = dwSenderID; + + BYTE checkSum = 0; + for (int i = 0; i < sizeof(CIpcPacket) - 1; i++) + { + checkSum += buffer[i]; + } + pIpcPacket->m_hdrCrc = checkSum; + nRet = nTotalLength; + } + else + { + nRet = -1; + } + } + else + { + nRet = -1; + *nResultLenNeeded = nTotalLength; + } + + return nRet; +} + +//----------------------------------------------------------------------------- +void CIpc::OnPacket(CIpcPacket* pPacket) +{ + if (!m_pIpcListener) + return; + + BYTE* pBuffer = (BYTE*)(pPacket + 1); + m_pIpcListener->OnMessage(this, pPacket->m_channel, pPacket->m_errorCode, pBuffer, pPacket->m_length); +} + +//----------------------------------------------------------------------------- +IIPCListener* CIpc::CreateListener(FCT_OnMessageEvent callback, FCT_OnEvent error, FCT_OnEvent overflow) +{ + CIpcListener* pListener = new CIpcListener; + pListener->messageCallback = callback; + pListener->errorCallback = error; + pListener->messageLostCallback = overflow; + return pListener; +} + +//----------------------------------------------------------------------------- +void CIpc::DestroyListener() +{ + delete m_pIpcListener; + m_pIpcListener = NULL; +} diff --git a/K2LABI/ABI/K2LABI.cpp b/K2LABI/ABI/K2LABI.cpp new file mode 100644 index 0000000..0f94156 --- /dev/null +++ b/K2LABI/ABI/K2LABI.cpp @@ -0,0 +1,25 @@ +#include "k2l-type.h" +#include "K2LABI.h" +#include "ABI.h" + +//static +IABI* CABIFactory::CreateAbi() +{ + return new CABI(); +} + +//static +void CABIFactory::DestroyAbi(IABI* pAbi) +{ + delete pAbi; +} + +K2LABI_API IABI* CreateABI (void) +{ + return new CABI(); +} + +K2LABI_API void DestroyABI (IABI* pAbi) +{ + delete pAbi; +}
\ No newline at end of file diff --git a/K2LABI/ABI/K2LABI.h b/K2LABI/ABI/K2LABI.h new file mode 100644 index 0000000..0fd1490 --- /dev/null +++ b/K2LABI/ABI/K2LABI.h @@ -0,0 +1,1889 @@ +/*=== K2L GmbH ===============================================================*/ +/** +\file + This file contains the API of the \ref ABI interface. + +\ingroup ABI + +\par COPYRIGHT (c) 2000-2011 by K2L GmbH + All rights reserved. +*/ +/*============================================================================== + Alle Rechte an der Software verbleiben bei der K2L GmbH. + + Die K2L GmbH raeumt dem Lizenznehmer nach vollstaendiger + Bezahlung der Lizenzgebuehr ein nicht ausschliessliches, + unwiderrufliches, nicht uebertragbares, zeitlich und geografisch + nicht beschraenktes Recht zur Nutzung der jeweils + auftragsgegenstaendlichen Software innerhalb des Lizenznehmers ein. + + Die Weitergabe des Nutzungsrechts durch den Lizenznehmer ist auf + dessen Zulieferer beschraenkt. Die Zulieferer sind zu verpflichten, + die Software nur im Rahmen von Projekten fuer den Lizenznehmer + zu verwenden; weitere Rechte der Zulieferer sind auszuschliessen. +===HEADER END=================================================================*/ +//@{ +#pragma once + +#include "k2l-type.h" + +/// \defgroup ABI Automotive Bus Interface +/// Detailed overview of the ABI library. + +namespace K2L +{ + namespace Automotive + { + namespace ABI + { + +/// Bus types. +/// \ingroup ABI +typedef enum +{ + UnknownBusId = 0x00, ///< Unknown channel. + + CAN1 = 0x10, ///< CAN Channel 1. + CAN2 = 0x11, ///< CAN Channel 2. + CAN3 = 0x12, ///< CAN Channel 3. + CAN4 = 0x13, ///< CAN Channel 4. + CAN5 = 0x14, ///< CAN Channel 5. + CAN6 = 0x15, ///< CAN Channel 6. + + MOST1 = 0x20, ///< MOST Channel 1 (DEPRECATED). + MOST_CONTROL1_AMS = 0x20, ///< MOST Channel 1 of control channel (AMS). It's also used for all MOST bus events. + + MOSTHIGH1 = 0x30, ///< MOST High Channel 1 (DEPRECATED). + MOST_ASYNC1_HIGH = 0x30, ///< MOST Channel 1 of asynchronous channel (MOST HIGH). + + FLEXRAY1 = 0x40, ///< FlexRay Channel 1. + + LIN1 = 0x50, ///< LIN Channel 1. + LIN2 = 0x51, ///< LIN Channel 2. + LIN3 = 0x52, ///< LIN Channel 3. + LIN4 = 0x53, ///< LIN Channel 4. + LIN5 = 0x54, ///< LIN Channel 5. + LIN6 = 0x55, ///< LIN Channel 6. + + XCAN1 = 0x60, ///< CAN Extended Channel 1. + XCAN2 = 0x61, ///< CAN Extended Channel 2. + XCAN3 = 0x62, ///< CAN Extended Channel 3. + XCAN4 = 0x63, ///< CAN Extended Channel 4. + XCAN5 = 0x64, ///< CAN Extended Channel 5. + XCAN6 = 0x65, ///< CAN Extended Channel 6. + + LINTP1 = 0x70, ///< LIN TP Channel 1. + LINTP2 = 0x71, ///< LIN TP Channel 2. + LINTP3 = 0x72, ///< LIN TP Channel 3. + LINTP4 = 0x73, ///< LIN TP Channel 4. + LINTP5 = 0x74, ///< LIN TP Channel 5. + LINTP6 = 0x75, ///< LIN TP Channel 6. + + MOST_CONTROL1_RAW = 0x80, ///< MOST Channel 1 of raw control channel (CMS). + + MOST_ASYNC1_RAW = 0x90, ///< MOST Channel 1 of raw asynchronous channel (ADS)., + + MOST_SYNC1 = 0xA0, ///< MOST Synchronous Channel 1. + + RELAY1 = 0xB0, ///< Relay 1. + + LINRAW1 = 0xC0, ///< LIN Raw Channel 1. + LINRAW2 = 0xC1, ///< LIN Raw Channel 2. + LINRAW3 = 0xC2, ///< LIN Raw Channel 3. + LINRAW4 = 0xC3, ///< LIN Raw Channel 4. + LINRAW5 = 0xC4, ///< LIN Raw Channel 3. + LINRAW6 = 0xC5, ///< LIN Raw Channel 4. + + MOST_ASYNC1_MEP = 0xD0 ///< MOST Channel 1 of asynchronous ethernet channel (MEP). +} Bus; + +/// Bus types. +/// \ingroup ABI +typedef enum +{ + CAN = 1, ///< Controller Area Network. + MOST = 2, ///< MOST (DEPRECATED). + MOST_CONTROL = 2, ///< MOST control channel. + MOSTHIGH = 3, ///< MOST high (DEPRECATED). + MOST_ASYNC = 3, ///< MOST asynchronous channel. + FLEXRAY = 4, ///< FlexRay. + LIN = 5, ///< Local Interconnect Network. + XCAN = 6, ///< CAN Extended. + LINTP = 7, ///< LIN Transport Protocol. + MOST_CONTROL_RAW = 8, ///< MOST raw control channel. + MOST_ASYNC_RAW = 9, ///< MOST raw asnychronous channel. + MOST_SYNC = 10, ///< MOST synchronous channel. + RELAY = 11, ///< Relay. + LIN_RAW = 12, ///< LIN raw channel. + MOST_ASYNC_MEP = 13 ///< MOST MEP asnychronous channel. +} BusType; + +/// Signal types for sweeping tx data. +/// \ingroup ABI +typedef enum +{ + sigLines = 0, ///< The signal looks like sequence of ascending/descending values. + sigZigzag = 1, ///< The signals look like sequence of ascending and then descending values. + sigBitShift = 2 ///< First sequence value of this signal type is 0, then goes value with all bit set to 1. And then goes values, that are degree of 2, i.e. 1, 2, 4, 8 and so on. After this the sequence repeats from the beginning. +} SignalType; + +/// Object type of an ABI object. +/// \ingroup ABI +typedef enum +{ + NullObject = 0x00, ///< NULL object. + ReceiverObject = 0x01, ///< Common receiver object. + TransmitterObject = 0x02, ///< Common transmitter object. + CanTpReceiverObject = 0x03, ///< CAN TP receiver object. + CanTpTransmitterObject = 0x04 ///< CAN TP transmitter object. +} ObjectType; + +/// Object state of an ABI object. +/// @ingroup ABI +typedef enum +{ + Created = 0x00, ///< Object has been created. + Started = 0x01, ///< Object has been started. + Stopped = 0x02, ///< Object has been stopped. + Deleted = 0x03 ///< Object has been deleted. +} ObjectState; + +/// Describes what kind of internal event occured. +/// \ingroup ABI +typedef enum +{ + paramTxMostQueueOverflow = 0, ///< The MOST TX queue has overflowed. + paramRxMostQueueOverflow = 1, ///< The MOST RX queue has overflowed. + paramTxCan1QueueOverflow = 2, ///< The CAN1 TX queue has overflowed. + paramTxCan2QueueOverflow = 3, ///< The CAN2 TX queue has overflowed. + paramTxCan3QueueOverflow = 4, ///< The CAN3 TX queue has overflowed. + paramTxCan4QueueOverflow = 5, ///< The CAN4 TX queue has overflowed. + paramRxCan1QueueOverflow = 6, ///< The CAN1 RX queue has overflowed. + paramRxCan2QueueOverflow = 7, ///< The CAN2 RX queue has overflowed. + paramRxCan3QueueOverflow = 8, ///< The CAN3 RX queue has overflowed. + paramRxCan4QueueOverflow = 9, ///< The CAN4 RX queue has overflowed. + paramTxIpcQueueOverflow = 10, ///< The IPC TX (from ABI device to PC) queue has overflowed. + paramOutOfMemory = 11, ///< The heap memory is full. This can happen if the PC is sending much faster, as the automotive bus can transport the data. + paramTxFlexrayQueueOverflow = 12, ///< The FlexRay TX queue has overflowed. + paramRxFlexrayQueueOverflow = 13, ///< The FlexRay RX queue has overflowed. + paramTxCan5QueueOverflow = 14, ///< The CAN5 TX queue has overflowed. + paramTxCan6QueueOverflow = 15, ///< The CAN6 RX queue has overflowed. + paramRxCan5QueueOverflow = 16, ///< The CAN5 TX queue has overflowed. + paramRxCan6QueueOverflow = 17, ///< The CAN6 RX queue has overflowed. + paramTimingSynchronisationModeChanged = 18, ///< Timing synchronisation mode changed (param1: mode). + paramTimeStampBaseChanged = 19 ///< TimeStamp base changed (param1: new timestamp (high) param2: new timestamp (low). +} Parameter; + +/// Bus events. +/// \ingroup ABI +typedef enum +{ + beMOSTStressNicMode = 10, ///< MOST StressNIC: Mode Changed (param1: mode). + beMOSTNetOn = 11, ///< MOST: Net on. + beMOSTNetOff = 12, ///< MOST: Net off. + beMOSTMPRChanged = 13, ///< MOST: MPR changed (param1: new MPR param2: old MPR). + beMOSTShortUnlock = 14, ///< MOST: Short unlock. + beMOSTCriticalUnlock = 15, ///< MOST: Critical unlock. + beMOSTLock = 16, ///< MOST: Stable lock. + beMOSTUnlock = 17, ///< MOST: Undefined unlock. + beMOSTNPRChanged = 18, ///< MOST: NPR changed (param1: new NPR). + beMOSTSBCChanged = 19, ///< MOST: SBC changed (param1: 1Byte none 1Byte Preset 1Byte Current 1Byte Total param2: 2Byte Free 1Byte Packet 1Byte Used). + beMOSTShutdownReasonChanged = 20, ///< MOST: Shutdown reason (MOST 150) changed (param1: Shutdown Reason). + + beFlexRayOnline = 21, ///< FlexRay: Bus online. + beFlexRayOffline = 22, ///< FlexRay: Bus offline. + beFlexRayBadHardware = 23, ///< FlexRay: Bad hardware. + beFlexRayBadConfiguration = 24, ///< FlexRay: Bad configuration. + beFlexRayTxChanged = 25, ///< FlexRay: Tx messages enabling changed (param1: enabled). + + beCANBusError = 31, ///< CAN: Bus error. + + beLINBusError = 41, ///< LIN: Bus error. + + beMOSTVolumeChanged = 50, ///< MOST: MOST: Volume changed (param1: 1Byte connector type 1Byte isInput 1Byte modifyLeft 1Byte modifyRight param2: volume). + beMOSTDiagnostic = 51, ///< MOST: Diagnostic event (param1: type param2: optional parameter). + beMOSTInitError = 52, ///< MOST: Init error. + beMOSTStartupFailed = 53, ///< MOST: Startup failed. + beMOSTStartupBusy = 54, ///< MOST: Startup busy. + beMOSTShutdownFailed = 55, ///< MOST: Shutdown failed. + beMOSTShutdownBusy = 56, ///< MOST: Shutdown busy. + beMOSTNetworkInterface = 57, ///< MOST: Network Interface status (param1: State). + beMOSTSystemErrorMonitor = 58, ///< MOST: System error monitor status (param1: Result). + beMOSTGroupAddressChanged = 59, ///< MOST: Group address changed (param1: New group address). + beMOSTNodeAddressChanged = 61, ///< MOST: Node Address changed (param1: New node address). + beMOSTDeviceModeChanged = 62, ///< MOST: Device Mode changed (param1: New device mode param2: Options). + beMOSTFrequencyChanged = 63, ///< MOST: MOST frequency changed (param1: new frequency). + beMOSTLowLevelRetryCountChanged = 64, ///< MOST: MOST low level retry count changed (param1: new count). + beMOSTMidLevelRetryCountChanged = 65, ///< MOST: MOST mid level retry count changed (param1: new count). + beMOSTHighLevelRetryCountChanged = 66, ///< MOST: MOST high level retry count changed (param1: new count). + beMOSTMPREqual = 67, ///< MOST: Maximum position range (MPR) equal (param1: mpr). + beMOSTIlluminationLevelChanged = 68, ///< MOST: MOST illumination level changed (param1: level). + beMOSTSpyChange = 69, ///< MOST SPY: State of MOST spy channels (param1: 1Byte status 1Byte control 1Byte async 1Byte sync (0 means false, >0 means true). + + beLINTPBusError = 70, ///< LINTP: Bus error. + + beCANTPRxConfigChanged = 80, ///< CANTP: Rx config changed (param1: 1Byte block size 1Byte separation time 2Byte consecutive frame timeout). + beCANTPTxConfigChanged = 81, ///< CANTP: Tx config changed (param1: 2Byte flow control timeout 2Byte clear to send timeout). + beCANTPPatternChanged = 82, ///< CANTP: Pattern changed (param1: pattern param2: 1 if pattern generator is active; otherwise 0). + + beMOSTMuteStateChanged = 90, ///< Audio: Mute state changed (param1: 1Byte connector type 1Byte isInput 1Byte reserved 1Byte reserved param2: muteState +} TBusEvent; + +/// This errors are returned from \ref ABICommands +/// and signalize if operation was executed successful. +/// \ingroup ABI +typedef enum +{ + tmRetValOk = 0, ///< Operation successful. + tmRetValNotImplemented = 1, ///< Function is not implemented. + tmRetValSystemNotReady = 2, ///< System is not ready. + tmRetValObjectAlreadyExists = 3, ///< Object already exists. + tmRetValObjectNotFound = 4, ///< Object not found. + tmRetValCannotExecute = 5, ///< Operation can not be executed. + tmRetValTooManyObjects = 6, ///< The maximum amount of transmitter / receiver objects are already allocated in the ABI device. + tmRetValTooManySignals = 7, ///< The maximum amount of sweep signals are already assigned to the transmitter in the ABI device. + tmRetValBadBusId = 8, ///< Bad bus ID. + tmRetValBadDataLength = 9, ///< Bad data length. + tmRetValBadBitPosition = 10, ///< Bad bit position. + tmRetValBadSignalType = 11, ///< Bad signal type. + tmRetValBadStepsNumber = 12, ///< Bad steps number. + tmRetValOutOfMemory = 13, ///< Device is out of memory. + tmRetValBadRepetitionsNumber = 14, ///< Bad repetition number. + tmRetValBadHandle = 15, ///< Bad handle passed. + tmRetValBadMessageId = 16, ///< Message ID was not correct. + tmRetValFunctionObsolete = 17, ///< Function is obsolete and not supported. + tmRetValBadParameter1 = 21, ///< Parameter 1 is not valid. + tmRetValBadParameter2 = 22, ///< Parameter 2 is not valid. + tmRetValBadParameter3 = 23, ///< Parameter 3 is not valid. + tmRetValBadParameter4 = 24, ///< Parameter 4 is not valid. + tmRetValBadParameter5 = 25, ///< Parameter 5 is not valid. + tmRetValBadParameter6 = 26, ///< Parameter 6 is not valid. + tmRetValBadParameter7 = 27, ///< Parameter 7 is not valid. + tmRetValBadParameter8 = 28, ///< Parameter 8 is not valid. + tmRetValBadParameter9 = 29, ///< Parameter 9 is not valid. + tmRetErrorDuringExecution = 30, ///< Error during executing the function., + tmRetErrorInvalidMessageFormat = 31 ///< Message format is invalid (e.g. CMS payload is malformed). +} TMErrorCode; + +/// Enum to select the desired informations. +/// \ingroup ABI +typedef enum +{ + FirmwareVersion = 0x01u, ///< Firmware version of MOCCA compact firmware. + HardwareVersion = 0x02u, ///< Hardware version of MOCCA compact. + SerialNumber = 0x03u, ///< Serialnumber of MOCCA compact mainboard. + SupportedFeatures = 0x04u, ///< Supported Features of abi firmware. + MacAddress = 0x05u, ///< MAC Address of MOCCA compact. + FpgaVersion = 0x06u, ///< FPGA firmware version. + CpldVersion = 0x07u, ///< CPLD firmware version. + SerialNumberPhyBoard = 0x40u, ///< Serialnumber of MOST phy board. + InicFirmwareVersion = 0x41u, ///< Firmware version of INIC. + InicConfigString = 0x42u, ///< Config string version of INIC firmware. + NetServicesVersion = 0x43u, ///< NetServices version., + SpynicFirmwareVersion = 0x44, ///< Firmware version of SPYNIC. + SpynicConfigString = 0x45, ///< Config string version of SPYNIC firmware. + SpynicHardwareVersion = 0x46, ///< Hardware version of SPYNIC. + SpynicApiVersion = 0x47, ///< API version of SPYNIC. + SpynicProductDate = 0x48, ///< Product Date of SPYNIC. + StressnicFirmwareVersion = 0x49,///< Firmware version of StressNIC. + StressnicConfigString = 0x4A, ///< Config string version of StressNIC firmware. + StressnicHardwareVersion = 0x4B,///< Hardware version of StressNIC. + StressnicApiVersion = 0x4C, ///< API version of StressNIC. + StressnicProductDate = 0x4D, ///< Product Date of StressNIC. + StressnicApiVersionInic = 0x4E ///< API version of StressNIC integrated INIC. +} BoardInformation; + +/// Synchronisation mode of hardware timestamp synchronisation. +/// \ingroup ABI +typedef enum +{ + SynchronisationStandalone = 0x00u, ///< Standalone mode. + SynchronisationMaster = 0x01u, ///< Master mode. + SynchronisationSlave = 0x02u ///< Slave mode. +} TimingSynchronisationMode; + +/// Absolute trigger command. +/// \ingroup ABI +typedef struct +{ + bool isActive; ///< Gets or sets a value indicating whether this instance is active. + unsigned long long timeStamp; ///< Gets or sets the timestamp when the command shall be executed (in ticks of 100ns). +} AbsoluteTriggerCommand; + +/// Relative trigger command. +/// \ingroup ABI +typedef struct +{ + bool isActive; ///< Gets or sets a value indicating whether this instance is active. + WORD delay; ///< Gets or sets the delay of the next command (in milliseconds). +} RelativeTriggerCommand; + +/// FlexRay channels. +/// \ingroup ABI +typedef enum +{ + A = 1, ///< Channel A. + B = 2, ///< Channel B. + AB = 3 ///< Channel A+B. +} FrChannel; + +/// TX Status of FlexRay. +/// \ingroup ABI +typedef enum +{ + flexraySuccess = 0x00, ///< Message was sent successful. + flexrayFailed = 0x01 ///< Message sending has failed. +} FlexrayTxStatus; + +/// MOST protocols. +/// \ingroup ABI +typedef enum +{ + CMS, ///< Control Message Service. + AMS, ///< Application Message Service. + ADS, ///< Asynchronous Data Service. + HIGH ///< MOST High protocol. +} MostProtocol; + +/// MOST device mode. +/// \ingroup ABI +typedef enum +{ + mostSlave = 0, ///< Slave mode. + mostStaticMaster = 1, ///< Static master mode. + mostBypass = 2, ///< Bypass mode. + mostNormalMaster = 3, ///< Master mode. + mostConstantLightMaster = 4 ///< Static master mode with constant light (MOST 150 only). +} MostMode; + +/// MOST device mode options. +/// @ingroup ABI +typedef enum +{ + NoOption = 0x00, ///< No option. + ForceDeviceMode = 0x01 ///< If the device is in a master mode and the network is in NetOn a Shutdown will be forced. +} DeviceModeOptions; + +/// Role of device in MOST ring. +/// \ingroup ABI +typedef enum +{ + bypassOff = 0, ///< Device participate in MOST ring and switch to the last valid mode of device. + bypassOn = 1 ///< Device is not participate in MOST ring. +} BypassMode; + +/// Determinates the destination addressing type of a received message. +/// \ingroup ABI +typedef enum +{ + logicaladdress = 0x00, ///< Message was sent to a logical node address. + nodeaddress = 0x01, ///< Message was sent to a node position address (0x0400 - 0x043F). + broadcast = 0x02, ///< Message was sent to a broadcast address (0x03C8 or 0x03FF). + groupcast = 0x03, ///< Message was sent to a group address (0x0300 - 0x03FF). + unknown = 0xFF ///< Receiver type is not available. +} ReceiveType; + +/// Bandwith of audio channel. +/// \ingroup ABI +typedef enum +{ + Mono16Bit = 0x00, ///< 16 Bit mono channel. + Stereo16Bit = 0x01, ///< 16 Bit stereo channel. + Stereo24Bit = 0x02 ///< 24 Bit stereo channel. +} AudioBandwidth; + +/// Frequency of MOST network. +/// \ingroup ABI +typedef enum +{ + Frequency44100Hz = 0x00, ///< 44,1 kHz. + Frequency48000Hz = 0x01 ///< 48 kHz. +} MostSamplingFrequency; + +/// Type of audio streaming event. +/// \ingroup ABI +typedef enum +{ + txAllocate, ///< Allocates new resources on MOST. + txAllocateConnect, ///< Allocates new resources on MOST and transmit the audio stream to them. + txConnect, ///< Transmits the audio stream on preallocated resources. + rxConnect ///< Receives an Audiostream from preallocated resources. +} AudioConnectionType; + +/// Entry in allocation table. +/// \ingroup ABI +typedef struct +{ + WORD connectionLabel; ///< Connection label. + WORD channelWidth; ///< Width of allocated channel in bytes. +} AllocationTableEntry; + +/// Type of audio streaming connector. +/// @ingroup ABI +typedef enum +{ + AudioConnectorSpdif = 0x00, ///< SPDIF connector. + AudioConnectorAnalog = 0x01, ///< Analog connector. + AudioConnectorAll = 0xFF ///< All supported connectors. +} AudioConnectorType; + +/// Entry in local label table. +/// \ingroup ABI +typedef struct +{ + WORD connectionLabel; ///< Connection label. + AudioConnectorType connectorType; ///< Audio connector type. + BYTE dummy; ///< Unused byte. +} LabelEntry; + +/// Delivers more detailed information, why the transmission of the MOST message failed. +/// \ingroup ABI +typedef enum +{ + mostControlWrongTarget = 0x0100, ///< Transmission failed. No response under chosen target address. + mostControlSuccess = 0x0110, ///< Transmission of all telegrams successful. + mostControlCrc = 0x0120, ///< Transmission of a telegram failed. Incorrect CRC. + mostControlBuf = 0x0121, ///< Transmission of a telegram failed. Receive buffer of target device was full. + mostControlSuccessAndCrc = 0x0130, ///< Combination in case of a group-/broadcast transmission. At least one device got the message correctly. At least one device rejected the message due to an incorrect CRC value. + mostControlSuccessAndBuf = 0x0131, ///< Combination in case of a group-/broadcast transmission. At least one device got the message correctly. At least one device didn not receive it due to a full receive buffer. + mostControlTimeout = 0x0180, ///< Timeout error. No response from lower layer. + mostControlNetOff = 0x0181, ///< Transmission failed, since MOST network is switched off. + mostControlFrmt = 0x0182, ///< Protocol error in the Port Message. + mostControlSync = 0x0183, ///< Transmission failed due to an synchronization failure between INIC and PMS. The PMS has been re-synchronized. + mostControlInternal = 0x0184, ///< Internal error. Undefined status identifier. + mostControlNoIcm = 0x0185, ///< You tried to send a ICM message (Tgt_Adr = 1 and FBlock INIC), which is reserved for the services of the MOST NetServices only. + mostControlProtectedMode = 0x0187, ///< You have called MsgSend() while the EHC is not attached to the INIC. It is not allowed to call any API function beside the Kernel function MostService() and the timer management functions until the re-initialization is completed. + mostControlSuccessAndTimeout = 0x0190, ///< Combination in case of a group-/broadcast transmission. Internal FBlocks received the message, while FBlocks on the network are not accessible due to a timeout error from the lower layer. + mostControlSuccessAndNetOff = 0x0191, ///< Combination in case of a group-/broadcast transmission. Internal FBlocks received the message, while FBlocks on the network are not accessible while the network is switched off. + mostControlSuccessAndSync = 0x0193, ///< Combination in case of a group-/broadcast transmission. Internal FBlocks received the message, while FBlocks on the network are not accessible due to a synchronization failure between INIC and PMS. + mostControlInvalidMessage = 0x01A0, ///< Not a valid CMS message. + mostControlRetry = 0x01A1, ///< Reserved. + + mostAsyncSuccess = 0x0200, ///< The packet was delivered successfully. The connection is held on until timeout (MHP_TIME_DELAY _END) or until connection is terminated by application. + mostAsyncErrorNac = 0x0201, ///< Error during transmission: At least one frame was not acknowledged after considering timeouts and retries. The connection was terminated automatically. + mostAsyncErrorKilled = 0x0202, ///< Error during transmission: The receiver device terminated the connection, before the packet has been transmitted completely. + mostAsyncErrorBuildCon = 0x0203, ///< Error during establishing the connection: The Start Connection telegram was not received. + mostAsyncErrorPrio = 0x0204, ///< Error during establishing the connection: The connection was rejected by the receiver, because the priority is to minor. The returned priority can be read out of the connection list entry (field Priority). + mostAsyncErrorScale = 0x0205, ///< Error during establishing the connection: The receiver sent an invalid scale value (0x00). + mostAsyncErrorNoBuf = 0x0206, ///< Error during connection establishing or transmission: The connection was terminated because an internal error occurred. After MHP_BUF_RETRY retries no internal wADS buffer was available. + mostAsyncKilledTx = 0x0208, ///< The transmission was canceled by the application of the sender prematurely. + mostAsyncErrorNdf = 0x0209, ///< Error during establishing the connection: The receiver sent an invalid NDF value (0x00). + mostAsyncLenZero = 0x0221, ///< The order is denied ( MhpSend() ), since the packet length has been set to zero. The entry is removed from the connection list. + mostAsyncEndReady = 0x0222, ///< The entry is removed from the connection list. This is not an error report, but this event can be used to get the information, when the connection is closed. + mostAsyncKilledRx = 0x0223, ///< The receiver device terminated the connection, after the packet has been transmitted completely. The sender is in hold state currently. + mostAsyncConfigNotOk = 0x0225, ///< The connection is not established, or is going to be terminated, due to system state NotOK. + mostAsyncLenTooBig = 0x0226, ///< The total size of packet exceeds the upper limit. The entry is removed from the connection list. + mostAsyncClose = 0x0227, ///< The connection is closed, due to transition from NetOn to NetOff or re-initialization of the MHP module while the connection was open. + mostAsyncAddressHandlerBusy = 0x02A1, ///< Function called failed, as the target address is 0xFFFF, and the Address Handler is busy. + mostAsyncNcsNotOk = 0x02A2, ///< Function called failed, as the System Configuration State is NotOK. + mostAsyncTxLenZero = 0x02A3, ///< Function called failed, as the Length field is zero. The entry is removed from the connection list. + mostAsyncInvTotalPacketLength = 0x02A4 ///< Function called failed, as the TotalPacketLength field exceeds the maximum size or the TotalPacketLength field is smaller than the Length field and not zero. The entry is removed from the connection list. +} MostTxStatus; + +/// Options to configure for MHP transmission. +/// @ingroup ABI +typedef enum +{ + DefaultMhpOptions = 0, ///< Default option set: Block acknowledge. + SingleBlockAcknowledge = 1 ///< Single block acknowledge. +} MostMhpOptions; + +/// Delivers more detailed information, why the reception of the MOST message failed. +/// @ingroup ABI +typedef enum +{ + MhpSuccess = 0x0200, ///< The receipt of one block was successfully. + MhpErrorNFrame = 0x0201, ///< Error during transmission: The required Null-Frame is missing. + MhpErrorFrame = 0x0202, ///< Error during transmission: Data frames are missing. + MhpErrorNoReady = 0x0203, ///< Error during transmission: After sending a "Start Connection" no "Ready for Data" received. + MhpErrorKilled = 0x0204, ///< Error during transmission: The sender device terminated the transmission prematurely. + MhpErrorNoBuf = 0x0205, ///< Error during transmission: The connection was terminated because an internal error occurred. + MhpErrorKilledRx = 0x0206, ///< The connection was canceled by receiver's application. + MhpClose = 0x0210 ///< The connection is closed (No new data received since the last rx event). +} MostRxStatus; + +/// Status of MOST illumination level. +/// @ingroup ABI +typedef enum +{ + IlluminationOff = 0, ///< Light is switched off. + IlluminationMinus3dB = 1, ///< Light is on and dimmed with -3dB. + IlluminationFull = 2 ///< Light is on. +} MostIlluminationLevel; + +/// Device mode of StressNIC. +/// @ingroup ABI +typedef enum StressNicMode +{ + Off = 0, ///< StressNIC is disconnected from MOST network. + Bypass = 1, ///< StressNIC is in Bypass mode. + Slave = 2 ///< StressNIC is in Slave mode. +} StressNicMode; + +/// <summary> +/// Options of MEP bridge. +/// </summary> +/// @ingroup ABI +typedef enum MepBridgeOptions +{ + None = 0, ///< No options activated. + DmaOptimization = 1 ///<Improve speed of bridge by using DMA from LAN chip to/from MediaLB. (If enabled MOST High and ADS are ignored.) +} MepBridgeOptions; + +/// CAN errors. +/// \ingroup ABI +typedef enum +{ + CanTxCounterNormal = 17, ///< The TX error counter of the CAN cell is in the normal range. + CanTxCounterWarning = 18, ///< The TX error counter of the CAN cell is in the warning range. + CanTxCounterErrorPassive = 19, ///< The TX error counter of the CAN cell is in the passive range. + CanTxCounterBusOff = 20, ///< The TX error counter of the CAN cell is in the bus off range. + CanRxCounterNormal = 33, ///< The RX error counter of the CAN cell is in the normal range. + CanRxCounterWarning = 34, ///< The RX error counter of the CAN cell is in the warning range. + CanRxCounterErrorPassive = 35, ///< The RX error counter of the CAN cell is in the passive range. + CanProtStuffError = 49, ///< Signals that a protocol stuffing error occured. + CanProtFormError = 50, ///< Signals that a protocol form error occured. + CanProtAckError = 51, ///< Signals that a acknowledge error occured. + CanProtBitError = 52, ///< Signals that a bit error occured. + CanProtCrcError = 53 ///< Signals that a CRC error occured. +} TCanError; + +/// CAN transceiver. +/// \ingroup ABI +typedef enum +{ + canTransceiverSlow = 1, ///< Fault tolerant CAN transceiver (TJA 1080). + canTransceiverFast = 2, ///< Highspeed CAN transceiver (TJA 1054). + canTransceiverSingleWireNormal = 3, ///< Signle wire CAN transceiver (NCV7356). Normal mode. + canTransceiverSingleWireHighSpeed = 4, ///< Signle wire CAN transceiver (NCV7356). High speed mode. + canTransceiverSingleWireHighVoltage = 5 ///< Signle wire CAN transceiver (NCV7356). High voltage mode. +} CanTransceiver; + +/// CAN baudrate settings. +/// \ingroup ABI +typedef enum +{ + canSpeed83 = 1, ///< Baudrate 83,3 kbps. + canSpeed100 = 2, ///< Baudrate 100 kbps. + canSpeed125 = 3, ///< Baudrate 125 kbps. + canSpeed500 = 4, ///< Baudrate 500 kbps. + canSpeed33 = 5, ///< Baudrate 33,3 kbps. + canSpeed66 = 6, ///< Baudrate 66,6 kbps. + canSpeed1000 = 7, ///< Baudrate 1000 kbps. + canSpeed250 = 8, ///< Baudrate 250 kbps. + canSpeedIndividual = 0xFF ///< Individual Baudrate. +} CanSpeed; + +/// TX Status of CAN. +/// \ingroup ABI +typedef enum { + canSuccess = 0x00, ///< Message was sent successful. + canFailed = 0x01 ///< Message sending has failed. +} CanTxStatus; + +/// Adressing type of CAN transport protocol. +/// \ingroup ABI +typedef enum +{ + tpNormal = 1, ///< ISO CAN TP normal addressing. + tpExtended = 2 ///< ISO CAN TP extended addressing. +} TPAddressingType; + +/// CAN transport protocol errors. +/// \ingroup ABI +typedef enum +{ + tpSuccess = 0, ///< Successful TP operation. + tpOutOfMemory = 1, ///< Out of memory during receiving of the first frame. + tpBadSingleFrame = 2, ///< Bad single frame. + tpBadFirstFrameLength = 3, ///< Bad length of the first frame. + tpBadFirstFrame = 4, ///< Bad first frame. + tpBadConsecutiveFrameLength = 5, ///< Bad length of the consecutive frame + tpBadConsecutiveFrameSequence = 6, ///< Bad sequence number of the consecutive frame. + tpBadMessageLength = 7, ///< Bad message length. + tpBadFlowStatus = 8, ///< Bad flow status of the TP driver. + tpUnexpectedFrame = 9, ///< Unexpected frame received. + tpUnexpectedCtrlInfo = 10, ///< Unexpected control information. + tpConsecutiveFrameTimeout = 11, ///< Timeout for the consecutive frame. + tpFlowControlTimeout = 12, ///< Timeout for the flow control. + tpFlowControlCTSTimeout = 13 ///< Timeout for the control clear to send. +} TPOpResult; + +/// LIN warnings and errors. +/// Members of this enum are used in event OnLinBusEvent(). +/// \ingroup ABI +typedef enum +{ + LinUnknownError = 0xFF, ///< Unknown type of error. + LinSyncHeaderError = 0x10, ///< No sync field after header. + LinBreakHeaderError = 0x11, ///< Unexpected break in header. + LinLowLevelFramingHeaderError = 0x21, ///< Low level framing error in header. + LinLowLevelOverflowHeaderError = 0x22, ///< Low level overflow error in header. + LinOverflowHeaderError = 0x23, ///< New header started before previous has been read. + LinParityHeaderError = 0x24, ///< Header parity error. + LinBreakResponseError = 0x31, ///< Unexpected break in response. + LinLowLevelFramingResponeError = 0x32, ///< Low level framing error in response. + LinLowLevelOverflowResponseError = 0x33, ///< Low level overflow error in response. + LinLengthResponseError = 0x34, ///< Response length does not match expected length. + LinChecksumResponseError = 0x35, ///< Response checksum error. + LinOverflowResponseError = 0x36, ///< New response started before previous has been read. + LinReadResponseError = 0x37 ///< Error while try to read the response. +} TLinError; + +/// LIN TP warnings and errors. +/// Members of this enum are used in event OnLinTpBusEvent(). +/// \ingroup ABI +typedef enum +{ + LinTp_NoError = 0x50, ///< No LIN-TP error was reported. + LinTp_TxTimeOut = 0x51, ///< LIN-TP Transmission timed out. + LinTp_RxTimeOut = 0x52, ///< LIN-TP Reception timed out. + LinTp_TxBusy = 0x53, ///< Can not send LIN-TP message, because TP communication is in progress. + LinTp_NadError = 0x54, ///< Received an other Node Address while a receiption was in progress. + LinTp_PciError = 0x55, ///< Received an invalid Protocol Control Information (PCI) field. + LinTp_InvalidLength = 0x56, ///< Received an invalid length field or LIN frame was smaller than 8 Byte. + LinTp_InvalidFrameCounter = 0x57, ///< Received an invalid frame counter value. This may happen if a frame was lost. + LinTp_InvalidCfFrame = 0x58, ///< Received an SF or FF frame. Expected to receive a CF frame. + LinTp_RxStartWithCF = 0x59 ///< Received an CF frame at the begin of the reception. +} TLinTpError; + +/// TX Status of LIN. +/// \ingroup ABI +typedef enum +{ + linSuccess = 0x00, ///< Message was sent successful. + linFailed = 0x01 ///< Message sending has failed. +} LinTxStatus; + +/// LIN spy event. +/// \ingroup ABI +typedef enum +{ + RxReady = 0x01, ///< Data are available. + RxFraming = 0x02, ///< Frame error occured. + RxBreak = 0x04, ///< Break symbol received. + RxOverrun = 0x08, ///< Hardware queue overflow. + RxPacketLength = 0x10 ///< LIN packet length is longer than allowed. +} TLinSpyEvent; + +class IABI; + +/*============================================================================*/ +/// \brief Interface of ABI event listener. +/// \note Abstract base class. So it has to be implemented. +/// \ingroup ABI +/*============================================================================*/ +class K2LABI_API IABIListener +{ +public: + virtual ~IABIListener() {} + + /// Called when error occured. + /// \param[out] pAbi ABI instance that received event. + virtual void OnError(IABI* pAbi) = 0; + + /// Called when message lost. + /// \param[out] pAbi ABI instance that received event. + virtual void OnMessageLost(IABI* pAbi) = 0; + + /// This event is raised on the first occurence (once), if a internal queue overflows. To read out the amount of occurrence and to clear the counter refer GetInternalState(). + /// \param[out] pAbi ABI instance that received event. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] tEvent Enumeration identifying the source of problem. + /// \param[out] param1 Reserved. + /// \param[out] param2 Reserved. + virtual void OnInternalEvent + ( IABI* pAbi + , unsigned long long timeStamp + , Parameter tEvent + , unsigned int param1 + , unsigned int param2 + ) = 0; + + /// This event can be raised for general purposes or costumer specific. The event will hold a string message, describing the event in human language. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] identifier Channel of the message. Delivers the possibility to group messages by their meanings. + /// \param[out] payload The string which describes the event in human languange. + /// \param[out] param2 Length of the string. + virtual void OnGeneralEvent + ( IABI* pAbi + , unsigned long long timeStamp + , BYTE identifier + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when state of bus is changed by another process. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. (Bus context) + /// \param[out] timeStamp The occurrence of the event, represented in steps of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] isStarted true: The bus has been started by another process. false: The bus has been stopped by another process. + /// \param[out] param1 Parameter1. + /// \param[out] param2 Parameter2. + /// \note isStarted = false: param1 = 0; param2 = 0 + /// \note isStarted = true: + /// \note LINx: param1 = 0; param2 = 0 + /// \note CANx: param1 = baudrate (type=CanSpeed); param2 = type of transceiver (type=CanTransceiver) + /// \note FLEXRAYx: param1 = 0; param2 = 0 + /// \note MOST_CONTROL_AMSx: param1 = device mode (type=MostMode); param2 = 0 + virtual void OnBusRunningStateChanged + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , bool isStarted + ) = 0; + + /// This event will be raised, when state of relay is changed by another process. + /// \param[out] abi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. (Bus context) + /// \param[out] timeStamp The occurrence of the event, represented in steps of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] isClosed If true the relay is closed. + virtual void OnRelayStateChanged + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , bool isClosed + ) = 0; + + + /// This event will be raised, when state of tx payload filter is changed by another process. + /// \param[out] abi ABI instance that received event. + /// \param[out] context Delivers the object, which was stored by the RegisterBusContext() method. (Bus context) + /// \param[out] timeStamp The occurrence of the event, represented in steps of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] isEnabled If true no payload is transmitted in tx events otherwise false. + virtual void OnTxPayloadFilterChanged + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , bool isEnabled + ) = 0; + + /// This event will be raised, when an object has changed its state. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] context Delivers the object, which was stored by the RegisterBusContext() method. (Bus context) + /// \param[out] timeStamp The occurrence of the event, represented in steps of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] type The type of the object. + /// \param[out] handle The handle. + /// \param[out] groupId The group id. + /// \param[out] state The state of the object. + virtual void OnObjectStateChanged + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , ObjectType type + , unsigned short handle + , BYTE groupId + , ObjectState state + ) = 0; + + /// This event will be raised, when a CAN Message has been received. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. (Bus context) + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] messageId The identifier of the message. + /// \param[out] payload The payload which was attached to the message. + /// \param[out] payloadLength The length of the attached payload. + virtual void OnCanRxMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , unsigned int messageId + , bool extended + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a CAN Message has been succesful sent. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] messageId The identifier of the message. + /// \param[out] extended Determinates if the CAN message used a CAN extended 29 bit identifier. True, if 29bit Identifier used. False if 11bit Identifier was used. + /// \param[out] payload The payload which was attached to the message. + /// \param[out] payloadLength The length of the attached payload. + virtual void OnCanTxMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , unsigned short handle + , Bus bus + , unsigned int messageId + , bool extended + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a CAN Message was not transmitted, because of bus errors. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] messageId The identifier of the message. + /// \param[out] extended Determinates if the CAN message used a CAN extended 29 bit identifier. True, if 29bit Identifier used. False if 11bit Identifier was used. + /// \param[out] payload The payload which was attached to the message. + /// \param[out] payloadLength The length of the attached payload. + virtual void OnCanTxFailedMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , unsigned short handle + , Bus bus + , unsigned int messageId + , bool extended + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a CAN bus error has occured. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] evt Enumeration identifying the type of bus event. + /// \param[out] error Enumeration identifying the type of bus error. + virtual void OnCanBusError + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , TBusEvent evt + , TCanError error + ) = 0; + + /// This event will be raised, when a MOST Message has been received. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] rcvType Enumeration identifying the type of receive message. + /// \param[out] source Address of source. + /// \param[out] prot MOST protocol. + /// \param[out] messageId The identifier of the message. + /// \param[out] fBlock The Function Block identifier. + /// \param[out] instance The Function Block instance number. + /// \param[out] function The function identifier of the FBlock. + /// \param[out] opType The Function Block operation type identifier. + /// \param[out] payload Message payload. + /// \param[out] payloadLength Payload length. + virtual void OnMostRxMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , ReceiveType rcvType + , unsigned short source + , MostProtocol prot + , unsigned int messageId + , BYTE fBlock + , BYTE instance + , unsigned short function + , BYTE opType + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a MOST Message has been received. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] status The status of reception. + /// \param[out] rcvType Enumeration identifying the type of receive message. + /// \param[out] source Address of source. + /// \param[out] prot MOST protocol. + /// \param[out] messageId The identifier of the message. + /// \param[out] fBlock The Function Block identifier. + /// \param[out] instance The Function Block instance number. + /// \param[out] function The function identifier of the FBlock. + /// \param[out] opType The Function Block operation type identifier. + /// \param[out] payload Message payload. + /// \param[out] payloadLength Payload length. + virtual void OnMostRxFailedMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , MostRxStatus status + , ReceiveType rcvType + , unsigned short source + , MostProtocol prot + , unsigned int messageId + , BYTE fBlock + , BYTE instance + , unsigned short function + , BYTE opType + , BYTE* payload + , int payloadLength) = 0; + + /// This event will be raised, when a MOST High Message has been received (>64kb). + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] status The status of reception. + /// \param[out] rcvType Enumeration identifying the type of receive message. + /// \param[out] source Address of source. + /// \param[out] prot MOST protocol. + /// \param[out] messageId The identifier of the message. + /// \param[out] fBlock The Function Block identifier. + /// \param[out] instance The Function Block instance number. + /// \param[out] function The function identifier of the FBlock. + /// \param[out] opType The Function Block operation type identifier. + /// \param[out] segmentationId The segmentation identifier of this data block. + /// \param[out] blockCounter The relative block counter of the data block in this packet transmission. + /// \param[out] payload Message payload. + /// \param[out] payloadLength Payload length. + virtual void OnMostHighExtRxMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , MostRxStatus status + , ReceiveType rcvType + , unsigned short source + , MostProtocol prot + , unsigned int messageId + , BYTE fBlock + , BYTE instance + , unsigned short function + , BYTE opType + , BYTE segmentationId + , unsigned short blockCounter + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a MOST Message has been succesful sent. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] destination Address of destination. + /// \param[out] prot MOST protocol. + /// \param[out] messageId The identifier of the message. + /// \param[out] fBlock The Function Block identifier. + /// \param[out] instance The Function Block instance number. + /// \param[out] function The function identifier of the FBlock. + /// \param[out] opType The Function Block operation type identifier. + /// \param[out] payload Message payload. + /// \param[out] payloadLength Payload length. + virtual void OnMostTxMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , unsigned short handle + , Bus bus + , unsigned short destination + , MostProtocol prot + , unsigned int messageId + , BYTE fBlock + , BYTE instance + , unsigned short function + , BYTE opType + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a MOST Message was not transmitted, because the receiver did not correctly acknowledge the message. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] destination Address of destination. + /// \param[out] prot MOST protocol. + /// \param[out] messageId The identifier of the message. + /// \param[out] fBlock The Function Block identifier. + /// \param[out] instance The Function Block instance number. + /// \param[out] function The function identifier of the FBlock. + /// \param[out] opType The Function Block operation type identifier. + /// \param[out] payload Message payload. + /// \param[out] payloadLength Payload length. + virtual void OnMostTxNAKMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , unsigned short handle + , Bus bus + , unsigned short destination + , MostProtocol prot + , unsigned int messageId + , BYTE fBlock + , BYTE instance + , unsigned short function + , BYTE opType + , BYTE* payload + , int payloadLength) = 0; + + /// This event will be raised, when a MOST Message was not transmitted, because of bus errors. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] status Result status of transmission. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] destination Address of destination. + /// \param[out] prot MOST protocol. + /// \param[out] messageId The identifier of the message. + /// \param[out] fBlock The Function Block identifier. + /// \param[out] instance The Function Block instance number. + /// \param[out] function The function identifier of the FBlock. + /// \param[out] opType The Function Block operation type identifier. + /// \param[out] payload Message payload. + /// \param[out] payloadLength Payload length. + virtual void OnMostTxFailedMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , MostTxStatus status + , unsigned short handle + , Bus bus + , unsigned short destination + , MostProtocol prot + , unsigned int messageId + , BYTE fBlock + , BYTE instance + , unsigned short function + , BYTE opType + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a MOST specific bus event has occured. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] evt Bus event identifier. + /// \param[out] param1 Depending on the type of bus event (evt), this parameter holds the main value which belongs to this event. This value is used for MPR, NPR, preset SBC (value >> 16 & 0xff), current SBC (value >> 8 & 0xff), total SBC (value & 0xff), group address (value | 0x300), node address. + /// \param[out] param2 Depending on the type of bus event (evt), this parameter holds the additional value which belongs to this event. This value is used for the free SBC (value >> 16 & 0xff), packet SBC (value >> 8 & 0xff), used SBC (value & 0xff). + virtual void OnMostEventMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , TBusEvent evt + , unsigned int param1 + , unsigned int param2 + ) = 0; + + /// This event will be raised, when a MOST High receive status event has occured. + /// \param[out] abi Used IABI instance. + /// \param[out] context Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp The occurrence of the event, represented in steps of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] status Status of event. + /// \param[out] messageId The identifier of the message. + /// \param[out] fBlock The Function Block identifier. + /// \param[out] instance The Function Block instance number. + /// \param[out] function The function identifier of the FBlock. + /// \param[out] opType The Function Block operation type identifier. + /// \param[out] source Address of source. + virtual void OnMostHighRxStatusEvent + ( IABI* abi + , void* context + , unsigned long long timeStamp + , Bus bus + , MostRxStatus status + , unsigned int messageId + , BYTE fBlock + , BYTE instance + , unsigned short function + , BYTE opType + , unsigned short source + ) = 0; + + /// This event will be raised, when a MOST High transmit status event has occured. + /// \param[out] abi Used IABI instance. + /// \param[out] context Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp The occurrence of the event, represented in steps of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] status Status of event. + /// \param[out] messageId The identifier of the message. + /// \param[out] fBlock The Function Block identifier. + /// \param[out] instance The Function Block instance number. + /// \param[out] function The function identifier of the FBlock. + /// \param[out] opType The Function Block operation type identifier. + /// \param[out] destination Address of destination. + virtual void OnMostHighTxStatusEvent + ( IABI* abi + , void* context + , unsigned long long timeStamp + , Bus bus + , MostTxStatus status + , unsigned int messageId + , BYTE fBlock + , BYTE instance + , unsigned short function + , BYTE opType + , unsigned short destination + ) = 0; + + /// Called when an action with the audio streaming interface was successful. + /// \param[out] pAbi Used IABI instance. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] label The connection label. + /// \param[out] type Type of event. + /// \param[out] bandwith The bandwith. + /// \param[out] isOpenEvent If true the action was an open action otherwise it was close. + /// \param[out] connector The used audio connector. + virtual void OnMostAudioStreamingEvent + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , unsigned int label + , AudioConnectionType type + , AudioBandwidth bandwith + , bool isOpenEvent + , AudioConnectorType connector + ) = 0; + + /// Called when an action with the audio streaming interface has failed. + /// \param[out] pAbi Used IABI instance. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] error The errorcode. + /// \param[out] type Type of event. + /// \param[out] bandwith The bandwith. + /// \param[out] isOpenEvent If true the action was an open action otherwise it was close. + /// \param[out] connector The used audio connector. + virtual void OnMostAudioStreamingError + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , unsigned short error + , AudioConnectionType type + , AudioBandwidth bandwith + , bool isOpenEvent + , AudioConnectorType connector + ) = 0; + + /// Called when the allocation table in SPYNIC changed. + /// \param[out] pAbi Used IABI instance. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] length Length of the lists. + /// \param[out] connectionLabels List of available connectionlabels. + /// \param[out] channelWidths List of channel widths of connection labels. + /// \remarks Only available for MOST50. + virtual void OnMostAllocationTableChanged + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , unsigned short& length + , AllocationTableEntry* allocationTable + ) = 0; + + /// This event will be raised, when a MOST MEP Message has been transmitted. + /// \param[out] abi Used IABI instance. + /// \param[out] context Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp The occurrence of the event, represented in steps of 100 nanoseconds. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] destination The destination address. + /// \param[out] payload The payload which was attached to the message. + /// \param[out] payloadLength The length of the attached payload. + virtual void OnMostMepTxMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , unsigned short handle + , Bus bus + , unsigned long long destination + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a MOST MEP Message has been received. + /// \param[out] abi Used IABI instance. + /// \param[out] context Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp The occurrence of the event, represented in steps of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] source The source address. + /// \param[out] payload The payload which was attached to the message. + /// \param[out] payloadLength The length of the attached payload. + virtual void OnMostMepRxMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , unsigned long long source + , BYTE* payload + , int payloadLength + ) = 0; + + /// Called when MOST MEP bridge status changed. + /// \param[out] abi Used IABI instance. + /// \param[out] context Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp The occurrence of the event, represented in steps of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] isEnabled If set to <c>true</c> bridge is enabled otherwise <c>false</c>. + /// \param[out] options Activated options. + virtual void OnMostMepBridgeStatusChanged + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , bool isEnabled + , MepBridgeOptions options + ) = 0; + + /// Called when MOST MAC address changed. + /// \param[out] abi Used IABI instance. + /// \param[out] context Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp The occurrence of the event, represented in steps of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] macAddress The mac address that have been set. + virtual void OnMostMacAddressChanged + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , unsigned long long macAddress + ) = 0; + + /// This event will be raised, when a LIN Message has been received. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] sourceAddress The idententifier identifying the source device. + /// \param[out] messageId The identifier of the message. + /// \param[out] payload The payload which was attached to the message. + /// \param[out] payloadLength The length of the attached payload. + virtual void OnLinRxMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , unsigned int sourceAddress + , unsigned int messageId + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a LIN Message has been succesful sent. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] targetAddress The idententifier addressing the target device. + /// \param[out] messageId The identifier of the message. + /// \param[out] payload The payload which was attached to the message. + /// \param[out] payloadLength The length of the attached payload. + virtual void OnLinTxMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , unsigned short handle + , Bus bus + , unsigned int targetAddress + , unsigned int messageId + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a LIN Message was not transmitted, because of bus errors. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] targetAddress The idententifier addressing the target device. + /// \param[out] messageId The identifier of the message. + /// \param[out] payload The payload which was attached to the message. + /// \param[out] payloadLength The length of the attached payload. + virtual void OnLinTxFailedMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , unsigned short handle + , Bus bus + , unsigned int targetAddress + , unsigned int messageId + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a LIN bus error has occured. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] evt Enumeration identifying the type of bus event. + /// \param[out] error Enumeration identifying the type of bus error. + virtual void OnLinBusError + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , TBusEvent evt + , TLinError error + ) = 0; + + /// This event will be raised, when a LIN TP Message has been received. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] messageId The identifier of the message. + /// \param[out] frameId Identifier of message. Request is 60 and response is 61. + /// \param[out] nodeAddress Address of the target node. + /// \param[out] serviceId Identifier of the service. + /// \param[out] payload The payload which was attached to the message. + /// \param[out] payloadLength The length of the attached payload. + virtual void OnLinTpRxMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , unsigned int messageId + , BYTE frameId + , BYTE nodeAddress + , BYTE serviceid + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a LIN TP Message has been succesful sent. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] messageId The identifier of the message. + /// \param[out] frameId Identifier of message. Request is 60 and response is 61. + /// \param[out] nodeAddress Address of the target node. + /// \param[out] serviceId Identifier of the service. + /// \param[out] payload The payload which was attached to the message. + /// \param[out] payloadLength The length of the attached payload. + virtual void OnLinTpTxMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , unsigned short handle + , Bus bus + , unsigned int messageId + , BYTE frameId + , BYTE nodeAddress + , BYTE serviceid + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a LIN TP Message was not transmitted, because of bus errors. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] messageId The identifier of the message. + /// \param[out] frameId Identifier of message. Request is 60 and response is 61. + /// \param[out] nodeAddress Address of the target node. + /// \param[out] serviceId Identifier of the service. + /// \param[out] payload The payload which was attached to the message. + /// \param[out] payloadLength The length of the attached payload. + virtual void OnLinTpTxFailedMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , unsigned short handle + , Bus bus + , unsigned int messageId + , BYTE frameId + , BYTE nodeAddress + , BYTE serviceid + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a LIN TP bus error has occured. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] evt Enumeration identifying the type of bus event. + /// \param[out] error Enumeration identifying the type of bus error. + virtual void OnLinTpBusError + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , TBusEvent evt + , TLinTpError error + ) = 0; + + /// This event will be raised, when a LIN Spy event has been received. + /// \param[out] pAbi Used IABI instance. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp The occurrence of the event, represented in steps of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] evt Bitmask. Use TLinSpyEvent to decode it. + virtual void OnLinSpyEvent + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , TLinSpyEvent evt + ) = 0; + + /// This event will be raised, when a LIN Spy message has been received. + /// \param[out] pAbi Used IABI instance. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp The occurrence of the event, represented in steps of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] payload The payload. + virtual void OnLinSpyMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , BYTE payload + ) = 0; + + /// This event will be raised, when a FlexRay Message has been received. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] messageId The identifier of the message. + /// \param[out] frameId The frame identifier. + /// \param[out] offset The offset of the used frame cycle. + /// \param[out] repetition The repetition of the used frame cycle. + /// \param[out] frChannel The used FlexRay channel(s). + /// \param[out] frCycle The cycle slot used for this message. + /// \param[out] payload The payload which was attached to the message. + /// \param[out] payloadLength The length of the attached payload. + virtual void OnFlexrayRxMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , unsigned int messageId + , unsigned short frameId + , BYTE offset + , BYTE repetition + , FrChannel frChannel + , unsigned short frCycle + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a FlexRay Message has been succesful sent. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] messageId The identifier of the message. + /// \param[out] frameId The frame identifier. + /// \param[out] offset The offset of the used frame cycle. + /// \param[out] repetition The repetition of the used frame cycle. + /// \param[out] frChannel The used FlexRay channel(s). + /// \param[out] frCycle The cycle slot used for this message. + /// \param[out] payload The payload which was attached to the message. + /// \param[out] payloadLength The length of the attached payload. + virtual void OnFlexrayTxMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , unsigned short handle + , Bus bus + , unsigned int messageId + , unsigned short frameId + , BYTE offset + , BYTE repetition + , FrChannel frChannel + , unsigned short frCycle + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a FlexRay Message was not transmitted, because of bus errors. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] messageId The identifier of the message. + /// \param[out] frameId The frame identifier. + /// \param[out] offset The offset of the used frame cycle. + /// \param[out] repetition The repetition of the used frame cycle. + /// \param[out] frChannel The used FlexRay channel(s). + /// \param[out] frCycle The cycle slot used for this message. + /// \param[out] payload The payload which was attached to the message. + /// \param[out] payloadLength The length of the attached payload. + virtual void OnFlexrayTxFailedMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , unsigned short handle + , Bus bus + , unsigned int messageId + , unsigned short frameId + , BYTE offset + , BYTE repetition + , FrChannel frChannel + , unsigned short frCycle + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a FlexRay specific bus event has occured. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] param1 Depending on the type of bus event (evt), this parameter holds the main value which belongs to this event. + /// \param[out] param2 Depending on the type of bus event (evt), this parameter holds the additional value which belongs to this event. + virtual void OnFlexrayEventMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , TBusEvent evt + ) = 0; + + /// This event will be raised, when a CAN TP Message has been received. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] srcmessageId The CAN TP source address. + /// \param[out] destmessageId The CAN TP destination address. + /// \param[out] tpAddressingType Determinates the type of CAN TP protocol. + /// \param[out] tpOpResult Enumaration determinating the result of the CAN TP transmission. + /// \param[out] payload The payload which was attached to the message. + /// \param[out] payloadLength The length of the attached payload. + virtual void OnCanTpRxMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , unsigned short handle + , Bus bus + , unsigned int srcMessageId + , unsigned int destMessageId + , TPAddressingType tpAddressingType + , TPOpResult tpOpResult + , BYTE* payload + , int payloadLength + ) = 0; + + /// This event will be raised, when a CAN TP Message has been succesful sent. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] handle The handle which was given to the correspondic transmitter / receiver. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] srcmessageId The CAN TP source address. + /// \param[out] destmessageId The CAN TP destination address. + /// \param[out] tpAddressingType Determinates the type of CAN TP protocol. + /// \param[out] tpOpResult Enumaration determinating the result of the CAN TP transmission. + virtual void OnCanTpTxMessage + ( IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , unsigned short handle + , Bus bus + , unsigned int srcMessageId + , unsigned int destMessageId + , TPAddressingType tpAddressingType + , TPOpResult tpOpResult + ) = 0; + + /// This event will be raised, when e.g the configuration of CAN TP has changed. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] pContext Delivers the object, which was stored by the RegisterBusContext() method. + /// \param[out] timeStamp Timestamp of event in unit of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] evt Enumeration identifying the type of bus event. + /// \param[out] param1 Depending on the type of bus event (evt), this parameter holds the main value which belongs to this event. + /// \param[out] param2 Depending on the type of bus event (evt), this parameter holds the additional value which belongs to this event. + virtual void OnCanEventMessage + (IABI* pAbi + , void* pContext + , unsigned long long timeStamp + , Bus bus + , TBusEvent evt + , unsigned int param1 + , unsigned int param2 + ) = 0; + + /// This event will be raised, when a message is received by the StressNIC. + /// \param[out] pAbi ABI instance that received event. + /// \param[out] context Delivers the object, which was stored by the RegisterBusContext() method. (Bus context) + /// \param[out] timeStamp The occurrence of the event, represented in steps of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] deviceid The source device id. + /// \param[out] fblockId The fblock identifier. + /// \param[out] instanceId The instance identifier. + /// \param[out] functionId The function identifier. + /// \param[out] opType The operation type. + /// \param[out] payload The payload. + /// \param[out] payloadLength The payload length. + virtual void OnStressNicMessageReceived + (IABI* abi + , void* context + , unsigned long long timeStamp + , Bus bus + , unsigned short deviceid + , BYTE fblockId + , BYTE instanceId + , unsigned short functionId + , BYTE opType + , BYTE* payload + , int payloadLength) = 0; + + /// Called when trigger level changed. + /// \param[out] abi ABI instance that received event. + /// \param[out] context Delivers the object, which was stored by the RegisterBusContext() method. (Bus context) + /// \param[out] timeStamp The occurrence of the event, represented in steps of 100 nanoseconds. + /// \param[out] bus The type and instance number of the bus. + /// \param[out] isActive true if the trigger level is active, otherwise false. + /// \param[out] isTx true if the trigger level was changed by MOCCA compact, otherwise false. + virtual void OnTriggerLevelChanged + (IABI* abi + , void* context + , unsigned long long timeStamp + , Bus bus + , bool isActive + , bool isTx) = 0; +}; + +/*============================================================================*/ +/// \brief Default implementation of IABIListener interface. To add custom functionality override the desired function with own code. +/// \ingroup ABI +/*============================================================================*/ +class K2LABI_API CABIListener : public IABIListener +{ +public: + virtual ~CABIListener() {} + + virtual void OnError(IABI* pAbi) {} + virtual void OnMessageLost(IABI* pAbi) {} + + virtual void OnInternalEvent (IABI* pAbi, unsigned long long timeStamp, Parameter tEvent, unsigned int param1, unsigned int param2){} + virtual void OnGeneralEvent (IABI* pAbi, unsigned long long timeStamp, BYTE identifier, BYTE* payload, int payloadLength){} + virtual void OnBusRunningStateChanged ( IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, bool isStarted){} + virtual void OnRelayStateChanged( IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, bool isClosed){} + virtual void OnTxPayloadFilterChanged( IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, bool isEnabled){} + virtual void OnObjectStateChanged( IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, ObjectType type, unsigned short handle, BYTE groupId, ObjectState state){} + + virtual void OnCanRxMessage (IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, unsigned int messageId, bool extended, BYTE* payload, int payloadLength){} + virtual void OnCanTxMessage (IABI* pAbi, void* pContext, unsigned long long timeStamp, unsigned short handle, Bus bus, unsigned int messageId, bool extended, BYTE* payload, int payloadLength){} + virtual void OnCanTxFailedMessage (IABI* pAbi, void* pContext, unsigned long long timeStamp, unsigned short handle, Bus bus, unsigned int messageId, bool extended, BYTE* payload, int payloadLength){} + virtual void OnCanBusError (IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, TBusEvent evt, TCanError error){} + virtual void OnCanEventMessage (IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, TBusEvent evt, unsigned int param1, unsigned int param2){} + + virtual void OnMostRxMessage (IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, ReceiveType rcvType, unsigned short source, MostProtocol prot, unsigned int messageId, BYTE fBlock, BYTE instance, unsigned short function, BYTE opType, BYTE* payload, int payloadLength){} + virtual void OnMostRxFailedMessage (IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, MostRxStatus status, ReceiveType rcvType, unsigned short source, MostProtocol prot, unsigned int messageId, BYTE fBlock, BYTE instance, unsigned short function, BYTE opType, BYTE* payload, int payloadLength){} + virtual void OnMostHighExtRxMessage (IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, MostRxStatus status, ReceiveType rcvType, unsigned short source, MostProtocol prot, unsigned int messageId, BYTE fBlock, BYTE instance, unsigned short function, BYTE opType, BYTE segmentationId, unsigned short blockCounter, BYTE* payload, int payloadLength){} + virtual void OnMostTxMessage (IABI* pAbi, void* pContext, unsigned long long timeStamp, unsigned short handle, Bus bus, unsigned short destination, MostProtocol prot, unsigned int messageId, BYTE fBlock, BYTE instance, unsigned short function, BYTE opType, BYTE* payload, int payloadLength){} + virtual void OnMostTxNAKMessage (IABI* pAbi, void* pContext, unsigned long long timeStamp, unsigned short handle, Bus bus, unsigned short destination, MostProtocol prot, unsigned int messageId, BYTE fBlock, BYTE instance, unsigned short function, BYTE opType, BYTE* payload, int payloadLength){} + virtual void OnMostTxFailedMessage (IABI* pAbi, void* pContext, unsigned long long timeStamp, MostTxStatus status, unsigned short handle, Bus bus, unsigned short destination, MostProtocol prot, unsigned int messageId, BYTE fBlock, BYTE instance, unsigned short function, BYTE opType, BYTE* payload, int payloadLength){} + virtual void OnMostEventMessage (IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, TBusEvent evt, unsigned int param1, unsigned int param2) {} + virtual void OnMostHighRxStatusEvent(IABI* abi, void* context, unsigned long long timeStamp, Bus bus, MostRxStatus status, unsigned int messageId, BYTE fBlock, BYTE instance, unsigned short function, BYTE opType, unsigned short source) {} + virtual void OnMostHighTxStatusEvent(IABI* abi, void* context, unsigned long long timeStamp, Bus bus, MostTxStatus status, unsigned int messageId, BYTE fBlock, BYTE instance, unsigned short function, BYTE opType, unsigned short destination) {} + + virtual void OnMostAudioStreamingEvent(IABI* pAbi, void* pContext, unsigned long long timeStamp, unsigned int label, AudioConnectionType type, AudioBandwidth bandwith, bool isOpenEvent, AudioConnectorType connector){} + virtual void OnMostAudioStreamingError(IABI* pAbi, void* pContext, unsigned long long timeStamp, unsigned short error, AudioConnectionType type, AudioBandwidth bandwith, bool isOpenEvent, AudioConnectorType connector){} + virtual void OnMostAllocationTableChanged( IABI* pAbi, void* pContext, unsigned long long timeStamp, unsigned short& length, AllocationTableEntry* allocationTable){} + + virtual void OnLinRxMessage(IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, unsigned int sourceAddress, unsigned int messageId, BYTE* payload, int payloadLength){} + virtual void OnLinTxMessage(IABI* pAbi, void* pContext, unsigned long long timeStamp, unsigned short handle, Bus bus, unsigned int targetAddress, unsigned int messageId, BYTE* payload, int payloadLength){} + virtual void OnLinTxFailedMessage(IABI* pAbi, void* pContext, unsigned long long timeStamp, unsigned short handle, Bus bus, unsigned int targetAddress, unsigned int messageId, BYTE* payload, int payloadLength){} + virtual void OnLinBusError(IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, TBusEvent evt, TLinError error){} + virtual void OnLinTpRxMessage( IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, unsigned int messageId, BYTE frameId, BYTE nodeAddress, BYTE serviceid, BYTE* payload, int payloadLength) {} + virtual void OnLinTpTxMessage( IABI* pAbi, void* pContext, unsigned long long timeStamp, unsigned short handle, Bus bus, unsigned int messageId, BYTE frameId, BYTE nodeAddress, BYTE serviceid, BYTE* payload, int payloadLength) {} + virtual void OnLinTpTxFailedMessage( IABI* pAbi, void* pContext, unsigned long long timeStamp, unsigned short handle, Bus bus, unsigned int messageId, BYTE frameId, BYTE nodeAddress, BYTE serviceid, BYTE* payload, int payloadLength) {} + virtual void OnLinTpBusError( IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, TBusEvent evt, TLinTpError error) {} + virtual void OnLinSpyEvent( IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, TLinSpyEvent evt) {} + virtual void OnLinSpyMessage( IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, BYTE payload) {} + + virtual void OnFlexrayRxMessage (IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, unsigned int messageId, unsigned short frameId, BYTE offset, BYTE repetition, FrChannel frChannel, unsigned short frCycle, BYTE* payload, int payloadLength){} + virtual void OnFlexrayTxMessage (IABI* pAbi, void* pContext, unsigned long long timeStamp, unsigned short handle, Bus bus, unsigned int messageId, unsigned short frameId, BYTE offset, BYTE repetition, FrChannel frChannel, unsigned short frCycle, BYTE* payload, int payloadLength){} + virtual void OnFlexrayTxFailedMessage (IABI* pAbi, void* pContext, unsigned long long timeStamp, unsigned short handle, Bus bus, unsigned int messageId, unsigned short frameId, BYTE offset, BYTE repetition, FrChannel frChannel, unsigned short frCycle, BYTE* payload, int payloadLength){} + virtual void OnFlexrayEventMessage (IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, TBusEvent evt){} + + virtual void OnCanTpRxMessage (IABI* pAbi, void* pContext, unsigned long long timeStamp, unsigned short handle, Bus bus, unsigned int srcMessageId, unsigned int destMessageId, TPAddressingType tpAddressingType, TPOpResult tpOpResult, BYTE* payload, int payloadLength){} + virtual void OnCanTpTxMessage (IABI* pAbi, void* pContext, unsigned long long timeStamp, unsigned short handle, Bus bus, unsigned int srcMessageId, unsigned int destMessageId, TPAddressingType tpAddressingType, TPOpResult tpOpResult){} + + virtual void OnStressNicMessageReceived (IABI* abi, void* context, unsigned long long timeStamp, Bus bus, unsigned short deviceId, BYTE fblockId, BYTE instanceId, unsigned short functionId, BYTE opType, BYTE* payload, int payloadLength) {} + + virtual void OnMostMepTxMessage ( IABI* pAbi, void* pContext, unsigned long long timeStamp, unsigned short handle, Bus bus, unsigned long long destination, BYTE* payload, int payloadLength ) {} + virtual void OnMostMepRxMessage( IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, unsigned long long source, BYTE* payload, int payloadLength) {} + virtual void OnMostMepBridgeStatusChanged( IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, bool isEnabled, MepBridgeOptions options ) {} + virtual void OnMostMacAddressChanged( IABI* pAbi, void* pContext, unsigned long long timeStamp, Bus bus, unsigned long long macAddress ) {} + + virtual void OnTriggerLevelChanged (IABI* abi, void* context, unsigned long long timeStamp, Bus bus, bool isActive, bool isTx) {} +}; + +/*============================================================================*/ +/// \brief Helper class to initialize the ABI device. +/// \ingroup ABI +/*============================================================================*/ + +typedef void (AbiIpcDevice_RxCB_t)( const uint8_t * data, uint32_t dataLength, void *cbArg); + +class K2LABI_API AbiIpcDevice +{ +public: + virtual ~AbiIpcDevice() {} + virtual int Send( const BYTE *data, DWORD length ) { return 0; } + virtual void SetReceivePriority( int prio ) {}; + virtual void SetReceiveCallback( AbiIpcDevice_RxCB_t receiveCB, void *cbArg ) {}; +}; + +/*============================================================================*/ +/// \brief Interface of ABI. +/// \ingroup ABI +/*============================================================================*/ +class K2LABI_API IABI +{ +public: + virtual ~IABI() { } + + /// Initialize ABI client instance. + /// \param[in] pInitData Device that should be connected to. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + virtual int Init(AbiIpcDevice* abiDevice) = 0; + + /// Initialize ABI client instance. + /// \param[in] pInitData Device that should be connected to. + /// \param[in] priority Priority of the receive thread. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + virtual int Init(AbiIpcDevice* abiDevice, int priority) = 0; + + /// Deinitialize ABI client instance. + /// \return Status message if operation succeeded. For more informations see \ref TMErrorCode. + virtual int Deinit(void) = 0; + + /// Start event processing of the ABI client. + /// \param[in] Listener that should be process incoming events. + virtual void Start(IABIListener* pListener) = 0; + + /// Stop event processing of the ABI client. + virtual void Stop(void) = 0; + + /// Gives the possibility to assign a object to a specific bus. This object will be given back in every callback which the specific bus was involved. + virtual void RegisterBusContext(Bus bus, void* context) = 0; + + /// Removes a assigned a object from a specific bus. + virtual void UnregisterBusContext(Bus bus) = 0; + + /// Returns the assigned object for the given bus. + /// \return The assigned object for the given bus, or NULL if there is was nothing registered. + virtual void* GetBusContext(Bus bus) = 0; + + /// Raw send method, which is internaly used by ABI to comunicate with ABI hardware. + /// \param[in] ifc Addresses the internal processing unit in the ABI device. + /// \param[in] function Function id which addresses the ABI command. + /// \param[in] data The request data, which will be send to the ABI device. + /// \param[in] len The length of the request data. + /// \param[in] resultLen The length of the response, which was answered from the ABI device. + /// \param[in] errorCode Errorcode, 0 if successful. + /// \return Byte array containing the response from the ABI device. + /// \remarks After this command a EndRequest call is required. + virtual BYTE* SendRequest(BYTE ifc, BYTE function, BYTE* data, int len, int& resultLen, BYTE& errorCode) = 0; + + /// Raw send method, which is internaly used by ABI to comunicate with ABI hardware. + /// \param[in] ifc Addresses the internal processing unit in the ABI device. + /// \param[in] function Function id which addresses the ABI command. + /// \param[in] data The request data, which will be send to the ABI device. + /// \param[in] len The length of the request data. + /// \param[in] resultLen The length of the response, which was answered from the ABI device. + /// \param[in] errorCode Errorcode, 0 if successful. + /// \param[in] timeout Timespan to wait for an answer of this request (in milliseconds). + /// \return Byte array containing the response from the ABI device. + /// \remarks After this command a EndRequest call is required. + virtual BYTE* SendRequest(BYTE ifc, BYTE function, BYTE* data, int len, int& resultLen, BYTE& errorCode, int timeout) = 0; + + /// Ends the request. + /// \remarks This call is required after analyzing the return value of SendRequest. Otherwise next Requests will be blocked. + /// </remarks> + virtual void EndRequest(void) = 0; + + /// Determinates if the ABI client is set into spy mode. When active, only harmless ABI commands are accepted. So no influence to the automotive buses is granted. + /// \return TRUE if spy is active, otherwise FALSE. + virtual bool IsSpyMode(void) = 0; + + /// Sets the ABI client into spy mode. When active, only harmless ABI commands are accepted. So no influence to the automotive buses is granted. + /// \param[in] bSpyMode Mode that should be set. + virtual void SetSpyMode(bool bSpyMode) = 0; + + /// Adds the id interval filter. + /// \param[in] bus The bus on that the filter should set. + /// \param[in] handle The handle that represents the filter. + /// \param[in] minId The min id. + /// \param[in] maxId The max id. + virtual void AddIdIntervalFilter(Bus bus, unsigned short handle, unsigned int minId, unsigned int maxId) = 0; + + /// Adds the masked id filter. + /// \param[in] bus The bus on that the filter should set. + /// \param[in] handle The handle that represents the filter. + /// \param[in] id The id. + /// \param[in] mask The mask. + virtual void AddMaskedIdFilter(Bus bus, unsigned short handle, unsigned int id, unsigned int mask) = 0; + + /// Deletes a selected filter. + /// \param[in] handle The handle that represents the filter. + virtual void RemoveFilter(unsigned short handle) = 0; +}; + +/*============================================================================*/ +/// \brief Factory to create new ABI instances. +/// \ingroup ABI +/*============================================================================*/ +class K2LABI_API CABIFactory +{ +public: + /// Creates new instance of ABI. + /// \return New ABI instance. + static IABI* CreateAbi(); + + /// Destroys instance of ABI. + /// \param[in] pAbi ABI instance to destroy. + static void DestroyAbi(IABI* pAbi); + +}; + + } + } +} + +/*============================================================================*/ +/* C Interface */ +/*============================================================================*/ + +extern "C" +{ + K2LABI_API K2L::Automotive::ABI::IABI* CreateABI (void); + K2LABI_API void DestroyABI (K2L::Automotive::ABI::IABI* pAbi); +} + +//@} +/*============================================================================*/ +/* END OF FILE */ +/*============================================================================*/ diff --git a/K2LABI/ABI/ResultParser.cpp b/K2LABI/ABI/ResultParser.cpp new file mode 100644 index 0000000..b5e39bc --- /dev/null +++ b/K2LABI/ABI/ResultParser.cpp @@ -0,0 +1,29 @@ +#include "k2l-type.h" +#include "ResultParser.h" +#include <string.h> + +BYTE* CResultParser::ToByteArray(ParamDef* pParams, int nParamCount, int& nResultLength) +{ + int nLength = 0; + for (int i = 0; i < nParamCount; i++) + { + nLength += pParams[i].m_nLength; + } + + BYTE* pBuffer = NULL; + if (nLength) + { + nLength = (nLength + 1) & ~1; + pBuffer = new BYTE[nLength]; + memset(pBuffer, 0, nLength); + BYTE* pTemBuf = pBuffer; + for(int i = 0; i < nParamCount; i++) + { + memcpy(pTemBuf, pParams[i].m_pData, pParams[i].m_nLength); + pTemBuf += pParams[i].m_nLength; + } + } + + nResultLength = nLength; + return pBuffer; +} diff --git a/K2LABI/ABI/ResultParser.h b/K2LABI/ABI/ResultParser.h new file mode 100644 index 0000000..8f2b049 --- /dev/null +++ b/K2LABI/ABI/ResultParser.h @@ -0,0 +1,13 @@ +#pragma once + +typedef struct ParamDef_t +{ + void* m_pData; + size_t m_nLength; +} ParamDef; + +class CResultParser +{ +public: + static BYTE* ToByteArray(ParamDef* pParams, int nParamCount, int& nResultLength); +}; |