Page 2
Internet: www.hms-networks.de E-Mail: info-ravensburg@hms-networks.de Support For problems or support with this product or other HMS products please request support at www.ixxat.com/support. Further international support contacts can be found on our webpage www.ixxat.com Copyright Duplication (copying, printing, microfilm or other forms) and the electronic distribution of this document is only allowed with explicit permission of HMS Technology Center Ravensburg GmbH.
The LIN2CAN Gateway API (in short: L2CAPI) serves as an interface for the configuration and controlling of the LIN2CAN Gateway hardware and for the access to the LIN message traffic. All functions of the LIN2CAN device can be used in own programs with the LIN2CAN gateway API. Specific test applications or PC based network simulations can be realized.
LIN-CAN-RS232 Gateway API (L2CAPI) 2 LIN-CAN-RS232 Gateway API (L2CAPI) 2.1 Basic structure The structure of the API is similar to that of a COM object. The API is sub-divided into interfaces and has a reference counter used for releasing the API. If an interface is requested, the counter is increased by one.
LIN-CAN-RS232 Gateway API (L2CAPI) 2.3 Overview of interfaces The API implements the following interfaces: • ILIN2CAN_API_Ctrl Serves to connect the API with the device or to disconnect the connection and query the connection status. • ILIN2CAN_GeneralConfig2 Serves to query or make the basic settings of the device such as name, LIN baud rate and startup operation.
LIN-CAN-RS232 Gateway API (L2CAPI) 2.4 Interface IUnknown The interface provides the following methods: • HRESULT QueryInterface([in] REFIID riid, [out] LPVOID *ppvObj) With QueryInterface, one of the interfaces listed in 2.3 can be queried. The call is the same as for L2CAPI_CreateInstance, the only difference being that here no new instance of the class is created, but a pointer of the required interfaces is returned.
LIN-CAN-RS232 Gateway API (L2CAPI) 2.5 Interface ILIN2CAN_API_Ctrl This interface provides the following methods: • Connect([in] PCHAR pszName, [in] PCHAR pszMode) With Connect the API is connected to the device by the stated interface. The name of the interface to be used is given in pszName e.g.
LIN-CAN-RS232 Gateway API (L2CAPI) 2.6 Interface ILIN2CAN_GeneralConfig2 This interface implements the following methods: • GetDeviceName([out] PSTRING psDeviceName) • SetDeviceName([in] PSTRING psDeviceName) Get/SetDeviceName serves to give the device a name. 16 characters are permitted including “\0”. • GetVersionInformation([out] PL2C_VersionInformation pVersionInfo); GetVersionInformation queries the version information of the device. The structure is as follows: struct char strFirmwareVersion[8];...
Page 11
LIN-CAN-RS232 Gateway API (L2CAPI) • GetSystemTime([out] PDWORD pdwSystemTime); • SetSystemTime([in] DWORD dwSystemTime); These functions serve to set and query the system time of the device. The system time is a counter value in millisecond steps that is used for the timestamp of the LIN messages of the message queue. •...
LIN-CAN-RS232 Gateway API (L2CAPI) 2.7 Interface ILIN2CAN_GatewayConfig2 Here the following settings can be made: • GetCANConfig([out] PL2C_CAN_Config pCANConfig); • SetCANConfig([in] PL2C_CAN_Config pCANConfig); This defines the setting of the CAN controller. The following structure is used: struct DWORD dwBaudrate; L2C_CANTransceiverMode nTransceiverMode; }L2C_CANConfig, *PL2C_CANConfig;...
Page 13
LIN-CAN-RS232 Gateway API (L2CAPI) struct L2C_IdentifierTranslation stLIN_IdentifierTranslation[64]; L2C_IdentifierTranslation stLIN_ErrorTranslation; L2C_IdentifierTranslation stGatewayActivation; L2C_IdentifierTranslation stScheduleSwitching; }L2C_TranslationConfig2, *PL2C_TranslationConfig2; Each of the 66 entries has the following structure: struct BOOL bValid; L2C_TranslationDirection nTranslationDir; BOOL b29BitIdentifier; DWORD dwCANID; }L2C_IdentifierTranslation, *PL2C_IdentifierTranslation; With bValid it is possible to define whether the entry is valid (TRUE for valid).
LIN-CAN-RS232 Gateway API (L2CAPI) 2.8 Interface ILIN2CAN_SlaveConfig This interface serves to configure the action table. The following methods are provided: • GetLINIDAction([in/out] PL2C_ActionEntry pActionEntry); • SetLINIDAction([in] PL2C_ActionEntry pActionEntry); The methods serve to query or set an entry of the action table. The following structure is used: struct BYTE bLINID;...
LIN-CAN-RS232 Gateway API (L2CAPI) 2.9 Interface ILIN2CAN_MasterConfig2 The Master Schedule table can be edited here. The following methods are available for this: • GetScheduleTable([in] BYTE bNumberScheduleTable, [out] PL2C_ScheduleEntry pScheduleTable, [out] PBYTE pbNumberEntries); • SetScheduleTable([in] BYTE bNumberScheduleTable, [in] PL2C_ScheduleEntry pScheduleTable ,[in] BYTE bNumberEntries);...
LIN-CAN-RS232 Gateway API (L2CAPI) 2.10 Interface ILIN2CAN_LINMsgQueue2 This interface serves to access the LIN message queue. The following functions are provided: • GetLINMsgQueueStatus([out] L2C_QueueStatus pQueueStatus); The status of the LIN queue can be queried here. struct BOOL bOverrun; BYTE bQueueSize; BYTE bUsedEntries;...
Only sync break, sync field, ID field and at least one data byte detected before timeout. LIN-ID Calculated checksum does not match the received checksum. If the LIN2CAN GW is operating in LIN Spec. 2.0 mode, this error may occur due data collision or invalid CRC mode setting.
LIN-CAN-RS232 Gateway API (L2CAPI) 2.11 Interface ILIN2CAN_Master_Slave2 This interface enables a master emulation by PC. The following functions are provided: • SendLINID([in] BYTE bLINID); The function sends the specified LIN ID on the bus. The LIN ID must be between 0x00 and 0x3F. •...
LIN-CAN-RS232 Gateway API (L2CAPI) 2.13 Brief overview of API All methods return an HRESULT error code S_OK in the event of success, otherwise a Windows error code 2.13.1 Interface: ILIN2CAN_GeneralConfig2 • GetDeviceName([out] PSTRING psDeviceName) Name of the device: pointer to a string with max. 16 characters. The last valid character is “\0”.
LIN-CAN-RS232 Gateway API (L2CAPI) 2.13.6 Interface: ILIN2CAN_Master_Slave2 • SendLINID([in] BYTE bLINID); bLINIDLIN ID between 0x00 and 0x3F • SendLINIDandData([in] PL2C_LINMessage2 pLINMessage2); pLINMessagedwTimeStamp not used • SendWakeup([in] BYTE bSignalDuration); bSignalDuration Duration of the wakeup signals in [ms], value between 1 and 255 L2C-API Manual, Version 1.6...
LIN-CAN-RS232 Gateway API (L2CAPI) 2.13.7 Data type definitions /***************************************************************************** constants and macros *****************************************************************************/ //*** Define LIN2CAN Error Facility Code #define L2C_ERROR_FACILITY 0xE0670000 //*** max lenght of an error string #define L2C_MAX_ERRORSTR //*** LIN Message CRC Types #define L2C_MSG_CRC_TYPE_DEFAULT #define L2C_MSG_CRC_TYPE_SPEC_1_3...
Page 27
LIN-CAN-RS232 Gateway API (L2CAPI) //*** Version Information Structure typedef struct char strFirmwareVersion[8]; //Firmware Version String char strHardwareVersion[8]; //Hardware Version String }L2C_VersionInformation, *PL2C_VersionInformation; //*** LIN Message Config typedef struct BYTE bMsgLen[64]; //LIN Data Length: 0 - 8 Bytes L2C_MessageCrcType nMsgCrcType[64]; //LIN CRC calculation type }L2C_MessageConfig, *PL2C_MessageConfig;...
Page 28
LIN-CAN-RS232 Gateway API (L2CAPI) //*** Gateway Mode (Standalone) Translation Configuration typedef struct L2C_IdentifierTranslation stLIN_IdentifierTranslation[64]; //Field for Identifier Translation //(LIN ID = Index) L2C_IdentifierTranslation stLIN_ErrorTranslation; //LIN Error to CAN ID Translation L2C_IdentifierTranslation stGatewayActivation; //Gateway Activation CAN ID L2C_IdentifierTranslation stScheduleSwitching; //Master Schedule table switching CAN ID }L2C_TranslationConfig2, *PL2C_TranslationConfig2;...
Page 29
LIN-CAN-RS232 Gateway API (L2CAPI) //*** Error List Lookup Table Structure typedef struct BOOL fIdValid; //Flag if ID is valid BYTE bErrorCode; //Error Code char strErrorMessage[512]; //Human readable error string }L2C_LINErrorLookupTable, *PL2C_LINErrorLookupTable; //*** Error List Lookup Table Structure #define L2C_LIN_ERROR_LOOKUP_TABLE_ENTRY_COUNT 12 const L2C_LINErrorLookupTable L2C_k_stLINErrorLookupTable[L2C_LIN_ERROR_LOOKUP_TABLE_ENTRY_COUNT] = FALSE,...
Page 30
LIN-CAN-RS232 Gateway API (L2CAPI) TRUE, 0x07, "The calculated checksum does not match the received checksum. If the LIN2CAN GW is operating in LIN Spec. 2.0 mode, this error may occur due data collision or invalid CRC mode setting." TRUE, 0x08, "The received data does not match the sent data.
Page 31
** - 0x07 The calculated checksum does not match the received checksum. If the LIN2CAN GW is operating in LIN Spec. 2.0 mode, this error may occur due data collision or invalid CRC mode setting. ** - 0x08 The received data does not match the sent data. this error may occurre due data colission in LIN Spec.
Need help?
Do you have a question about the LIN2CAN and is the answer not in the manual?
Questions and answers