HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 HD CAN Module Programmer’s Guide (Linux) Page 1 of 24 Hatteland Display AS, Åmsosen, N-5578 Nedre Vats, Norway Tel: (+47) 4814 2200 - mail@hatteland-display.com - www.hatteland-display.
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 INDEX INDEX .......................................................................................................................................... 2 Revision History ............................................................................................................................ 3 Abbreviation................................................
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 Revision History Created Approved Rev Date By Date By Description 1 2013.08.18 Wei Jing 2013.09.25 Joakim Emanuelsson Preliminary Version HD CAN Library V1.0.207 2 2013.09.25 Wei Jing 2013-09-25 Joakim Emanuelsson HD CAN Library V1.0.224 CAN FW V1.
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 1. Introduction Along with the Hatteland Display external CAN module, a library set is provided for customized development under Linux environment. It provides the full control of the target CAN module, such as Device Open/Close, Communication Module Connect/Disconnect, Message Send/Receive and Periodic Message send.
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 2. Usage of CAN Library 2.1 2.1.1 Installation Installation Instruction for Binary DEB packages DEB packages should be installed on Ubuntu systems. API installation package consists from three binary packages: hdj2534 (basic package that contains hdj2534.
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 Page 6 of 24 Hatteland Display AS, Åmsosen, N-5578 Nedre Vats, Norway Tel: (+47) 4814 2200 - mail@hatteland-display.com - www.hatteland-display.
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 3. Example Application /************************************************************************** **********//** * @file test_demo_CAN.
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 enum passThruFuncNum { NO_FUNCTION = 0, PASSTHRU_OPEN, PASSTHRU_CLOSE, PASSTHRU_CONNECT, PASSTHRU_DISCONNECT, PASSTHRU_READ_MSG, PASSTHRU_WRITE_MSG, PASSTHRU_START_PERIODIC_MSG, PASSTHRU_STOP_PERIODIC_MSG, PASSTHRU_START_MSG_FILTER, PASSTHRU_STOP_MSG_FILTER, PASSTHRU_SET_PROGRAMMING_VOLTAGE, PASSTHRU_READ_VERSION, PASSTHRU_GET_LAST_ERROR, PASSTHRU_IOCTL,
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 static void callPassThruClose() { PassThruClose(deviceId); } /************************************************************************** **********//** * @brief Function to Connect Channel *************************************************************************** ************/ static void callPassThruConnect() { int baudSel; int protoSel; int chanSel; in
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 { unsigned long msgNum = 1; unsigned long *msgNumPtr = &msgNum; unsigned long timeout = 0; unsigned int id = 0x10; int chanSel; int msgPtrSel; int msgNumPtrSel; J2534_ERROR_CODE err; PASSTHRU_MSG *rxPassThruMsgPtr = rxPassThruMsg; J2534_RxStatus rxStatus; err = PassThruReadMsgs(channel_1, rxPassThruMsgPtr, msgNumPtr, timeout); if (err == STATUS_NOERROR) {
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 /************************************************************************** **********//** * @brief Function to Write Messages *************************************************************************** ************/ static void callPassThruWriteMsgs() { unsigned int id = 0x10; unsigned long msgNum = 1; unsigned long *msgNumPtr = &msgNum; unsigned int dlc
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 *************************************************************************** ************/ static void callPassThruStartMsgFilter() { int protoSel; int addrSel; int chanSel; int filterIdSel = 0; int filterTypeSel = PASS_FILTER; unsigned int maskId = 0; unsigned int pattId = 0; int msgPtrSel; PASSTHRU_MSG *filterMaskPassThruMsgPtr = &filterMaskPassThruMsg;
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 filterPattPassThruMsg.Data[0] = static_cast(pattId >> 24); filterPattPassThruMsg.Data[1] = static_cast(pattId >> 16); filterPattPassThruMsg.Data[2] = static_cast(pattId >> 8); filterPattPassThruMsg.Data[3] = static_cast(pattId >> 0); //Set Standard ID(0/Standard;1/Extended) filterFlags.bits.
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 callPassThruOpen(); //Connect Channel_1 CAN 125000bps callPassThruConnect(); //Soft Reset the module callPassThruReset(); //Re-Open Device callPassThruOpen(); //Connect Channel_1 CAN 125000bps callPassThruConnect(); //Write a single message callPassThruWriteMsgs(); //Set Read Message filter 0 callPassThruStartMsgFilter(); //Read one single message callPas
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 4. Appendix a) J2534_ERROR_CODE J2534::PassThruClose ( unsigned long DeviceID ) This function is used to close the connection to a Pass-Thru Device. All periodic messages will be stopped, filters will be cleared, and all pins will return to their default state (see Section 6.8). This function must be called before an application exits.
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 c) J2534_ERROR_CODE J2534::PassThruDisconne ct unsigned ( long ChannelI D ) This function is used to terminate a logical connection with a protocol channel. If the function is successful, a value of STATUS_NOERROR is returned.
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 f) J2534_ERROR_CODE J2534::PassThruIoctl ( unsigned long ChannelID, J2534_IOCTL IoctlID, void * pInput, void * pOutput ) This function is used to read and write all the protocol hardware and software configuration parameters. If the function is successful, a value of STATUS_NOERROR is returned.
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 h) J2534_ERROR_CODE J2534::PassThruReadMsgs ( unsigned long channelID, PASSTHRU_MSG * pMsg, pNumMsgs unsigned long * , unsigned long timeout ) This function reads messages and indications from the receive buffer. All messages and indications shall be read in the order that they occurred on the bus.
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 i) J2534_ERROR_CODE J2534::PassThruReadVersion unsigned ( long DeviceID, char * pFirmwareVer sion, char * pLibVersion, char * pApiVersion ) This function returns the version strings associated with the library. If the function is successful, a value of STATUS_NOERROR is returned.
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS k) J2534_ERROR_CODE J2534::PassThruS tartMsgFilter DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 ( unsigned long ChannelI D, J2534_FILTER FilterType , PASSTHRU_MSG * pMaskMsg , PASSTHRU_MSG * pPattern Msg, PASSTHRU_M SG * pFlowControlMsg, unsigned long * pFilterID ) This function starts filtering of incoming messages. If the function is successful, a value of STATUS_NOERROR is returned.
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 l) J2534_ERROR_CODE J2534::PassThruStartPer iodicMsg ( unsigned long ChannelID, PASSTHRU_MS G* pMsg, unsigned long * pMsgID, unsigned long TimeInterv al ) This function will immediately queue the specified message for transmission, and repeat at the specified interval.
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 n) J2534_ERROR_CODE J2534::PassThruStopPeriodi cMsg unsigned ( long unsigned long ChannelI D, MsgID ) This function stops the specified periodic message. If the function is successful, a value of STATUS_NOERROR is returned. After this call the MsgID will be invalid. Parameters: [in] ChannelID The channel ID assigned by the PassThruConnect function.
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 o) J2534_ERROR_CODE J2534::PassThruWriteMsg s ( unsigned long ChannelID, PASSTHRU_MS G* pMsg, unsigned long * pNumMsgs , unsigned long Timeout ) This function is used to send messages. The messages are placed in the buffer and sent in the order they were received.
HD CAN Module Programmer’s Guide (Linux) All intellectual properties belongs to Hatteland Display AS DOC101356-1_ - rev 2 – 2013-09-24 - Created by:6644 p) J2534_ERROR_CODE J2534::PassThruReset( void ) This function resets gateway. Parameters Returns Status, see function return codes in hdj2534.h. Page 24 of 24 Hatteland Display AS, Åmsosen, N-5578 Nedre Vats, Norway Tel: (+47) 4814 2200 - mail@hatteland-display.com - www.hatteland-display.