Advertisement

Quick Links

LIN2CAN API (L2CAPI)
MANUAL
ENGLISH

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the LIN2CAN and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for IXXAT LIN2CAN

  • Page 1 LIN2CAN API (L2CAPI) MANUAL ENGLISH...
  • 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.
  • Page 3: Table Of Contents

    Content Introduction ..................5 LIN-CAN-RS232 Gateway API (L2CAPI) ........6 2.1 Basic structure ................ 6 2.2 Creating the API object ............6 2.3 Overview of interfaces ............7 2.4 Interface IUnknown ..............8 2.5 Interface ILIN2CAN_API_Ctrl ..........9 2.6 Interface ILIN2CAN_GeneralConfig2 ........10 2.7 Interface ILIN2CAN_GatewayConfig2 ........
  • Page 5: Introduction

    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.
  • Page 6: Lin-Can-Rs232 Gateway Api (L2Capi)

    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.
  • Page 7: Overview Of Interfaces

    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.
  • Page 8: Interface Iunknown

    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.
  • Page 9: Interface Ilin2Can_Api_Ctrl

    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.
  • Page 10: Interface Ilin2Can_Generalconfig2

    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. •...
  • Page 12: Interface Ilin2Can_Gatewayconfig2

    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).
  • Page 14: Interface Ilin2Can_Slaveconfig

    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;...
  • Page 15: Interface Ilin2Can_Masterconfig2

    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);...
  • Page 16: Interface Ilin2Can_Linmsgqueue2

    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;...
  • Page 17: Error Overview

    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.
  • Page 18: Interface Ilin2Can_Master_Slave2

    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. •...
  • Page 19: Overview: Permitted Api Calls / Operation Mode

    LIN-CAN-RS232 Gateway API (L2CAPI) 2.12 Overview: Permitted API calls / operation mode Operation mode Function GetDeviceName SetDeviceName GetVersionInformation GetLINBaudrate SetLINBaudrate GetOperationMode SetOperationMode GetStartUpOpMode SetStartUpOpMode GetStandbyTime SetStandbyTime GetSystemTime SetSystemTime GetLinMessageConfig SetLinMessageConfig LoadSettingsFromFlash SaveSettingsToFlash GetCANConfig SetCANConfig GetGatewayTranslation SetGatewayTranslation GetLINIDAction SetLINIDAction GetScheduleTable SetScheduleTable GetScheduleTableCount GetLINMsgQueueStatus ResetLINMsgQueueOverrun...
  • Page 20: Brief Overview Of Api

    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”.
  • Page 21 LIN-CAN-RS232 Gateway API (L2CAPI) • SetOperationMode([in] L2C_OperationMode nOperationMode); • GetStartUpOpMode([out] PL2C_OperationMode pnOpe- rationMode); #define L2C_OP_MODE_SLAVE 4 #define L2C_OP_MODE_MASTER 5 #define L2C_OP_MODE_GATEWAY_SLAVE 3 #define L2C_OP_MODE_GATEWAY_MASTER 3 • SetStartUpOpMode ([in] L2C_OperationMode nOperationMode); • GetStandbyTime([out] PWORD pwStandbyTime); Resolution in [s] 0xFFFF for never •...
  • Page 22: Interface: Ilin2Can_Gatewayconfig2

    LIN-CAN-RS232 Gateway API (L2CAPI) 2.13.2 Interface: ILIN2CAN_GatewayConfig2 • GetCANConfig([out] PL2C_CAN_Config pCANConfig); struct DWORD dwBaudrate; L2C_CANTransceiverMode nTransceiverMode; }L2C_CANConfig; CAN transceiver baud rate 10, 20, 50, 100, 125, 250, 500, 1000 CAN transceiver modes #define L2C_CAN_TRANSCEIVER_LOWSPEED 0 #define L2C_CAN_TRANSCEIVER_HIGHSPEED 1 • SetCANConfig([in] PL2C_CAN_Config pCANConfig); •...
  • Page 23: Interface: Ilin2Can_Slaveconfig

    LIN-CAN-RS232 Gateway API (L2CAPI) 2.13.3 Interface: ILIN2CAN_SlaveConfig • GetLINIDAction([in/out] PL2C_ActionEntry pActionEntry); [in] pActionEntry->bLINID [out] “remaining” struct BYTE bLINID; L2C_LINIDAction nAction; BYTE pbAddInfo[64]; BYTE bAddInfoLen; }L2C_ActionEntry; //*** Slave Mode (Standalone) LIN ID Actions #define L2C_CAN_ACTION_IGNORE 4 #define L2C_CAN_ACTION_SEND_LINDATA 5 • SetLINIDAction([in] PL2C_ActionEntry pActionEntry); 2.13.4 Interface: ILIN2CAN_MasterConfig2 •...
  • Page 24: Interface: Ilin2Can_Linmsgqueue2

    LIN-CAN-RS232 Gateway API (L2CAPI) 2.13.5 Interface: ILIN2CAN_LINMsgQueue2 • GetLINMsgQueueStatus([out] L2C_QueueStatus pQueue- Status); struct BOOL bOverrun; BYTE bQueueSize; BYTE bUsedEntries; }L2C_QueueStatus; • ResetLINMsgQueueOverrun(); • GetLINMsgQueueEntry([out] PL2C_LINMessage2 pLIN- Message2); struct DWORD dwTimeStamp; BYTE bLINID; BYTE pbData[8]; BYTE bDataLen; L2C_MessageCrcType nMsgCrcType; }L2C_LINMessage2, *PL2C_LINMessage2; If a LIN error has occurred, this is signaled by the ID 0x40.
  • Page 25: Interface: Ilin2Can_Master_Slave2

    LIN-CAN-RS232 Gateway API (L2CAPI) 2.13.6 Interface: ILIN2CAN_Master_Slave2 • SendLINID([in] BYTE bLINID); bLINIDLIN ID between 0x00 and 0x3F • SendLINIDandData([in] PL2C_LINMessage2 pLINMessage2); pLINMessagedwTimeStamp 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...
  • Page 26: Data Type Definitions

    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.

Table of Contents