Home

TIP810-SW-82 - powerbridge.de

image

Contents

1. TEWS amp The Embedded I O Company TECHNOLOGIES TIP810 SW 82 Linux Device Driver CAN Bus IP Version 1 2 x User Manual Issue 1 2 3 July 2008 TEWS TECHNOLOGIES GmbH TEWS TECHNOLOGIES LLC Am Bahnhof 7 Phone 49 0 4101 4058 0 9190 Double Diamond Parkway Phone 1 775 850 5830 25469 Halstenbek Germany Fax 49 0 4101 4058 19 Suite 127 Reno NV 89521 USA Fax 1 775 201 0347 www tews com e mail info tews com www tews com e mail usasales tews com TIP810 SW 82 Linux Device Driver CAN Bus IP Supported Modules TEWS amp TECHNOLOGIES This document contains information which is proprietary to TEWS TECHNOLOGIES GmbH Any reproduction without written permission is forbidden TEWS TECHNOLOGIES GmbH has made any effort to ensure that this manual is accurate and complete However TEWS TECHNOLOGIES GmbH reserves the right to change the product described This product has been designed to operate with IndustryPack compatible carriers Connection to incompatible hardware is likely to cause serious TEWS TECHNOLOGIES GmbH is not liable for any damage arising out of the application or use of the 2004 2008 by TEWS TECHNOLOGIES GmbH Date April 29 2003 March 2 2004 April 30 2004 October 16 2006 November 26 2007 TIP810 in this document at any time without notice damage device described herein Issue Description 1 0 First Issue 1 1 Support for DEVFS and SMP 1 2 Update File List 1 2 1 Fil
2. 05 FE FE 80 05 05 05 05 FE BEE FE EF FE FE FE FE FE FE FE FE FE FE FE FE FE EE FE FE FE EE FE EF PE FE FE EE FE FE FE EF FE EE FE FE FE FE FE FE EE FE FE FE FE FE FE FE FE FE FE FE FE EE FE FE FE FE FE FE FE EE PE FE FE FE FE FE FE EE FE FE FE FE FE FE FE IP ID Memory FE FE EF FE FE Space FE FE FE EE FE FE FE FE FE FE 49 PE 50 FE 41 PE 43 FE B3 PE 01 FE 20 PE PE 00 PE 00 PE OC FE 9D FE OA PE 00 FE 00 PE FE 00 FE 00 FE 00 FE 00 FE 00 FE 00 FE 00 FE FE 00 FE 00 FE 00 FE 00 FE Enable Ints for 0xca06f000 00 FE 00 FE 00 FE FE 00 00 00 00 Compact PCI Page 36 of 37 TEWS amp TECHNOLOGIES If you have trouble with the driver please enable the debug output and send us a copy of the results The kernel context output is generated with printk and is appended to var log messages or wherever it is piped in your system For debugging please run tail f var log messages at first and then install the driver TIP810 SW 82 Linux Device Driver Pa
3. SW 82 Linux Device Driver Page 28 of 37 TEWS amp TECHNOLOGIES ModeRegister This parameter receives the content of the mode register RxMessageCounterMax This parameter contains the peak value of messages in the RXFIFO This internal counter value will be reset to 0 after reading EXAMPLE include lt tip810 h gt int ids int result T810_STATUS CanStatus result ioctl fd T810_IOCGCANSTATUS char amp CanStatus if result lt 0 handle ioctl error else printf ModeRegister 0x 02X n CanStatus ModeRegister ERRORS EFAULT An error occurred during memory data transfer between kernel and user space SEE ALSO SJA1000 Product Specification Manual TIP810 SW 82 Linux Device Driver Page 29 of 37 TEWS amp TECHNOLOGIES 3 5 7 T810 IOCENABLE SELFTEST NAME T810_IOCENABLE SELFTEST Enable self test mode DESCRIPTION This ioctl function enables the self test facility of the SJA1000 CAN controller In this mode a full node test is possible without any other active node on the bus using the self reception facility The CAN controller will perform a successful transmission even if there is no acknowledge received Also in self test mode the normal functionality is given that means the CAN controller is able to receive messages from other nodes and can transmit message to other nodes if any connected The optional argument pointer can be omitted for this ioctl fu
4. does not exist This is the only error code returned by the driver other codes may be returned by the I O system during open For more information about open error codes see the GNU C Library description Low Level Input Output SEE ALSO GNU C Library description Low Level Input Output TIP810 SW 82 Linux Device Driver Page 11 of 37 TEWS amp TECHNOLOGIES 3 2 close NAME close close a file descriptor SYNOPSIS include lt unistd h gt int close int filedes DESCRIPTION The close function closes the file descriptor filedes EXAMPLE int fd if close fd 0 handle close error conditions RETURNS The normal return value from close is 0 In the case of an error a value of 1 is returned The global variable errno contains the detailed error code ERRORS ENODEV The requested minor device does not exist This is the only error code returned by the driver other codes may be returned by the I O system during close For more information about close error codes see the GNU C Library description Low Level Input Output SEE ALSO GNU C Library description Low Level Input Output TIP810 SW 82 Linux Device Driver Page 12 of 37 3 3 read NAME read read from a device SYNOPSIS include lt unistd h gt TEWS amp TECHNOLOGIES ssize_t read int filedes void butter size_t size DESCRIPTION The read function reads a CAN message from
5. int result T810_TIMING BitTimingParam BitTimingParam TimingValue T810_100KBIT BitTimingParam ThreeSamples FALSE result ioctl fd T810_IOCSBITTIMING char amp BitTimingParam if result lt 0 handle ioctl error ERRORS EACCES The CAN controller is in operating mode This mode can be changed only in reset mode EFAULT An error occurred during memory data transfer between kernel and user space SEE ALSO tip810 h for predefined bus timing constants SJA1000 Product Specification Manual 6 5 1 2 BUS TIMING REGISTER TIP810 SW 82 Linux Device Driver Page 22 of 37 TEWS amp TECHNOLOGIES 3 5 2 T810_ IOCSSETFILTER NAME T810_IOCSSETFILTER Setup acceptance filter DESCRIPTION This ioctl function modifies the acceptance filter of the specified CAN controller device The acceptance filter compares the received identifier with the acceptance filter and decides whether a message should be accepted or not If a message passes the acceptance filter it is stored in the RXFIFO The acceptance filter is defined by the acceptance code registers and the acceptance mask registers The bit patterns of messages to be received are defined in the acceptance code register The corresponding acceptance mask registers allow defining certain bit positions to be don t care an 1 at a bit position means don t care A pointer to the caller s parameter buffer 7870_F LTER is passed by the parameter
6. the driver from the module directory lib modules lt version gt misc enter make uninstall e Update kernel module dependency description file depmod aq TIP810 SW 82 Linux Device Driver Page 7 of 37 TEWS amp TECHNOLOGIES 2 3 Install device driver into the running kernel e To load the device driver into the running kernel login as root and execute the following commands modprobe tip810drv e After the first build or if you are using dynamic major device allocation it is necessary to create new device nodes on the file system Please execute the script file makenode to do this If your kernel has enabled a device file system devfs or sysfs with udev then you have to skip running the makenode script Instead of creating device nodes from the script the driver itself takes creating and destroying of device nodes in its responsibility sh makenode On success the device driver will create a minor device for each TIP810 module found The first TIP810 can be accessed with device node dev tip810_0 the second TIP810 with device node dev tip810_1 the third TIP810 with device node dev tipb810_2 and so on The allocation of device nodes to physical TIP810 modules depends on the search order of the IPAC carrier driver Please refer to the IPAC carrier user manual Loading of the TIP810 device driver will only work if kernel KMOD support is installed necessary carrier board drivers already installed and the kernel dep
7. 810 SW 82 SRC tar gz to the desired target directory The command tar xzvf TIP810 SW 82 SRC tar gz will extract the files into the local directory e Login as root and change to the target directory e Copy tip810 h to usr include Before building a new device driver the TEWS TECHNOLOGIES IPAC carrier driver must be installed properly because this driver includes the header file jpac_carrier h which is part of the IPAC carrier driver distribution Please refer to the IPAC carrier driver user manual in the directory path CARRIER SW 82 on the separate distribution media TIP810 SW 82 Linux Device Driver Page 6 of 37 TEWS amp TECHNOLOGIES 2 1 Build and install the device driver e Login as root e Change to the target directory e To create and install the driver in the module directory lib modules lt version gt misc enter make install For Linux kernel 2 6 x there may be compiler warnings claiming some undefined ipac_ symbols These warnings are caused by the IPAC carrier driver which is unknown during compilation of this TIP driver The warnings can be ignored e Also after the first build we have to execute depmod to create a new dependency description for loadable kernel modules This dependency file is later used by modprobe to automatically load the correct IPAC carrier driver modules depmod aq 2 2 Uninstall the device driver e Login as root e Change to the target directory e Toremove
8. AULT An error occurred during memory data transfer between kernel and user space SEE ALSO SJA1000 Product Specification Manual 6 4 15 ACCEPTANCE FILTER TIP810 SW 82 Linux Device Driver Page 24 of 37 TEWS amp TECHNOLOGIES 3 5 3 T810_IOCBUSON NAME T810_IOCBUSON Enter the bus on state DESCRIPTION This ioctl function sets the specified CAN controller into the Bus On state After an abnormal rate of occurrences of errors on the CAN bus or after driver startup the CAN controller enters the Bus Off state This control function resets the reset mode bit in the mode register The CAN controller begins the busoff recovery sequence and resets the transmit and receive error counters If the CAN controller counts 128 packets of 11 consecutive recessive bits on the CAN bus the Bus Off state is exited The optional argument can be omitted for this ioctl function Before the driver is able to communicate over the CAN bus after driver startup this control function must be executed EXAMPLE include lt tip810 h gt int fds int result result ioctl fd T810_IOCBUSON if result lt 0 handle ioctl error ERRORS This ioctl function returns no specific error codes SEE ALSO SJA1000 Product Specification Manual 6 4 3 MODE REGISTER MOD TIP810 SW 82 Linux Device Driver Page 25 of 37 TEWS amp TECHNOLOGIES 3 5 4 T810_IOCBUSOFF NAME T810_IOCBUSOFF Enter t
9. C Carrier Driver Due to the design of the Carrier Driver it is sufficient to install the IPAC Carrier Driver once even if multiple IPAC Device Drivers are used Please refer to the CARRIER SW 82 User Manual for a detailed description how to install and setup the CARRIER SW 82 device driver and for a description of the TEWS TECHNOLOGIES IPAC Carrier Driver concept TIP810 SW 82 Linux Device Driver Page 5 of 37 TEWS amp TECHNOLOGIES 2 Installation The directory TIP810 SW 82 on the distribution media contains the following files TIP810 SW 82 1 2 3 pdf This manual in PDF format TIP810 SW 82 SRC tar gz_ GZIP compressed archive with driver source code Release txt Release information ChangeLog txt Release history The GZIP compressed archive TIP810 SW 82 SRC tar gz contains the following files and directories Directory path tip810 tip810 c Driver source code tip81Odef h Driver include file tip810 h Driver include file for application program sja1000 h Driver include file CAN Controller Spec makenode Script to create device nodes on the file system Makefile Device driver make file example tip810exa c Example application example Makefile Example application make file include config h Driver independent library header file include tpmodule h Kernel independent library header file include tpmodule c Kernel independent library source code file In order to perform an installation extract all files of the archive TIP
10. E A N E S A EE E E E A E E A E 19 3 5 1 T8710 JOGSBIT TIMING EE 21 3 5 2 T8102 IOCSSE TFILTER innos a E A A 23 3 5 3 T8170 IOGBUSON errer E A ENAA 25 3 5 4 T8102 OC BUSO EE 26 3 5 5 T810 Leier EE 27 3 5 6 T810 IOCGCANSTATUS eseni radne ananasa AAAA ARRAN KRASKA A RREA RAAR A 28 3 5 7 T810 IOCENABLE SELFTEST rinsar inanin naana ANANE RRAN AANRAAI 30 3 5 8 T810 IOCDISABLE SELFTEST wsscccvevsasecenstacccecsvancdeevtanccvessancccestaacdecvvancedevtaaccedtvadeccestaes 31 3 5 9 T810 IOCENABLE LISTENONLY secsrssinsena insid a 32 3 5 10 T810 IOCDIGADLE USTENONUN 33 goli T8SIOMOCSSET EIMM Micvsicccvesenenevsaniecevtanceneivaarecavaaheenctvanrdsccsantentavaarscavedieenetearrecacbuscendlvants 34 3 6 Step by Step Driver Initialization eceeeeeeceeeseeeceeeneeeeenneeeeeenseaeeeenseaeeeensnaeeeenseeeeeenseeneeenas 35 blo Ue e A E 36 TIP810 SW 82 Linux Device Driver Page 3 of 37 TEWS amp TECHNOLOGIES 1 Introduction 1 1 Device Driver The TIP810 SW 82 Linux device driver allows the operation of a TIP810 CAN Bus IP on Linux operating systems Because the TIP810 device driver is stacked on the TEWS TECHNOLOGIES IPAC carrier driver it is necessary to install also the appropriate IPAC carrier driver Please refer to the IPAC carrier driver user manual for further information The TIP810 device driver includes the following functions Transmission and receive of Standard and Extended Identifiers Standard bit rates from 5 kbi
11. E_LISTENONLY The optional argument pointer can be omitted in this ioctl function This ioctl command will be accepted only in reset mode BUSOFF Enter T810_ IOCBUSOFF first otherwise you will get an error EACCES EXAMPLE include lt tip810 h gt int fd int result result ioctl fd T810 DISABLE LISTENONLY if result lt 0 handle ioctl error ERRORS EACCES The CAN controller is in operating mode This mode can be changed only in reset mode SEE ALSO SJA1000 Product Specification Manual 6 4 3 MODE REGISTER MOD TIP810 SW 82 Linux Device Driver Page 33 of 37 TEWS amp TECHNOLOGIES 3 5 11 T810_lIOCSSETLIMIT NAME T810_IOCSSETLIMIT Set new error warning limit DESCRIPTION This ioctl function sets a new error warning limit in the corresponding CAN controller register The default value after hardware reset is 96 The new error warning limit will be set in an unsigned char variable A pointer to this variable is passed by the argument pointer arg to the driver This ioctl command will be accepted only in reset mode BUSOFF Enter T810_ IOCBUSOFF first otherwise you will get an error EACCES EXAMPLE include lt tip810 h gt int fd int result unsigned char limit limit 200 result ioctl fd T810_IOCSSETLIMIT char amp limit if result lt 0 handle ioctl error ERRORS EACCES The CAN controller
12. SG_BUF In the case of an error a value of 1 is returned The global variable errno contains the detailed error code ERRORS EINVAL EFAULT ECONNREFUSED EAGAIN ETIME EINTR SEE ALSO Invalid argument This error code is returned if the size of the message buffer is too small Invalid pointer to the message buffer The controller is in bus off state and unable to transmit messages Resource temporarily unavailable the call might work if you try again later This error occurs only if the device is opened with the flag O_NONBLOCK set The allowed time to finish the write request is elapsed This occurs if currently no message object is available or if the CAN bus is overloaded and the priority of the message identifier is too low Interrupted function call an asynchronous signal occurred and prevented completion of the call When this happens you should try the call again GNU C Library description Low Level Input Output TIP810 SW 82 Linux Device Driver Page 18 of 37 3 5 ioctl NAME ioctl device control functions SYNOPSIS include lt tip810 h gt include lt sys ioctl h gt int ioctl int filedes int request void argp DESCRIPTION TEWS amp TECHNOLOGIES The ioctl function sends a control code directly to a device specified by filedes causing the corresponding device to perform the requested operation The argument request specifies the control code for the opera
13. UG_INTR symbol controls debugging output from the ISR TIP810 TIP810 TIP810 Get bus error interrupt Get transmit interrupt Get receiv interrupt tip810_0 tips10_0 tip810_1 The TIP810_DEBUG_VIEW symbol controls debugging output from the remaining part of the driver TIP810 TIP810 00000000 00000010 00000020 00000030 00000040 00000050 00000060 00000070 00000080 00000090 00000040 000000B0 000000C0 000000D0 TIP810 00000000 00000010 00000020 00000030 TIP810 TIP810 SW 82 Linux Device Driver IP I O Memory Space TIP810 CAN Bus IP version 1 2 3 Probe new TIP810 mounted on lt T IPAC Carrier gt at slot C 2007 11 26 lt 6 gt EWS TECHNOLOGIES FE 01 FE 00 FE 3C FE 00 FE 00 FE 00 FE Zb FE FE DA FE 00 FE 00 FE 00 FE 00 FE 60 FE 00 FE 43 00 FE 00 FE 00 FE 00 FE 00 FE FE PE ER FE FE PE FE 00 FE 00 FE 00 FE 00 FE 00 FE 00 FE 00 BE FE 05 PE 05 FE 05 FE 05 FE 05 PE 05 FE 05 PE FE 05 FE 05 FE 05 FE 05 FE 05 FE 05 FE 05 FE FE 05 FE 05 FE 05 FE 05 FE 05 FE 05 FE 05 FE FE 05 FE 05 FE 05 FE 05 FE 05 FE 05 FE
14. _IOCGCANSTATUS NAME T810_IOCGCANSTATUS Returns CAN controller status information DESCRIPTION This ioctl function returns the actual contents of several CAN controller registers for diagnostic purposes A pointer to the callers status buffer T870_STATUS is passed by the parameter pointer arg to the driver typedef struct unsigned char ArbitrationLostCapture unsigned char ErrorCodeCapture unsigned char TxErrorCounter unsigned char RxErrorCounter unsigned char ErrorWarningLimit unsigned char StatusRegister unsigned char ModeRegister unsigned char RxMessageCounterMax T810_STATUS PT810_STATUS ArbitrationLostCapture This parameter receives content of the arbitration lost capture register This register contains information about the bit position of losing arbitration ErrorCodeCapture This parameter receives content of the error code capture register This register contains information about the type and location of errors on the bus TxErrorCounter This parameter receives content of the TX error counter register This register contains the current value of the transmit error counter RxErrorCounter This parameter receives content of the TX error counter register This register contains the current value of the receive error counter ErrorWarningLimit This parameter receives content of the error warning limit register StatusRegister This parameter receives content of the status register TIP810
15. elist modified introduction enhanced new address TEWS LLC 1 2 2 UDEV description added Filelist corrected 1 2 3 Carrier Driver description added TIP810 SW 82 Linux Device Driver July 7 2008 Page 2 of 37 4 TEWS amp TECHNOLOGIES Table of Contents INTRODUCTION E 4 MED DOVICE Eet 4 1 2 IPAC Catrier Driver esst ic ShacccccekssnciccadsacecacaseeneGasdancdanad AE ANARAN AESAAT AES 5 INSTALLATION ssisisisisishststscstsastidststtesdshsastidststsbbdsisisniastndegsdstsashsdsastabdasnsiensiansinesiansians 6 2 1 Build and install the device Ariver 2 ccccceceeeeeeeeeeeeeeeeeneeeaeeeeeeeen eens eanee sessed seneenaeeeseeeeaseneenaees 7 2 2 Uninstall the device driver iaiicccicsieccncei ci tisccateceateied ccadeutecuctetes cunncuteeneret EES shaneuadexereseosundentees 7 2 3 Install device driver into the running kernel cccceseeeceeeeneeeeeeeeeeeeesneeseeesneeseeeeeeseeesnenseeesnaes 8 2 4 Remove device driver from the running kernel cccccseeccceeeeeceeeseeeeeeeseeeseeeeeeseeeseeeseeeseenseeeenes 8 2 5 Change Major Device NUMDEL cssecceseesseeeeseeeeneeeeeeeeeencaeenseeeeneeeeseaesasaeeenseaeseesaseaesaseeeeneneeas 9 2 6 Receive Queue COnfiguration ccccseccsseeeeesecesseeeeseeeeeeeeeseaeseseeeenseaesseesesaesaseaeseeeaeseaesaseeneeeneeees 9 DEVICE INPUT OUTPUT FUNCTIONS see NEEN NN 10 ta OPIN EE 10 Bi e o1 1 0 E 12 We a EE 13 WINS A E bse AA AE A E A A E E A EE 16 sE MOCO E EA
16. endency file is up to date If KMOD support isn t available you have to build either a new kernel with KMOD installed or you have to install the IPAC carrier kernel modules manually in the correct order please refer to the IPAC carrier driver user manual 2 4 Remove device driver from the running kernel e To remove the device driver from the running kernel login as root and execute the following command modprobe tip810drv r If your kernel has enabled devfs or sysfs udev all dev tip810_x nodes will be automatically removed from your file system after this Be sure that the driver isn t opened by any application program If opened you will get the response tip810drv Device or resource busy and the driver will still remain in the system until you close all opened files and execute modprobe r again TIP810 SW 82 Linux Device Driver Page 8 of 37 TEWS amp TECHNOLOGIES 2 5 Change Major Device Number The TIP810 driver uses dynamic allocation of major device numbers per default If this isn t suitable for the application it s possible to define a major number for the driver To change the major number edit the file tip810 c change the following symbol to appropriate value and enter make install to create a new driver TIP810_ MAJOR Valid numbers are in range between 0 and 255 A value of 0 means dynamic number allocation Example define TIP810_MAJOR 122 2 6 Receive Queue Configu
17. ge 37 of 37
18. he bus off state DESCRIPTION This ioctl function sets the specified CAN controller into the Bus Off state After execution of this control function the CAN controller is completely removed from the CAN bus and cannot communicate until the control function T810_IOCBUSON is executed Note During a pending write of another concurrent thread it s not possible to set the device bus off The optional argument pointer can be omitted for this ioctl function EXAMPLE include lt tip810 h gt int fd int result result ioctl fd T810_IOCBUSOFF if result lt 0 handle ioctl error ERRORS EBUSY Another concurrent thread is writing to the device Try it again later EIO Unable to enter the BUSOFF mode SEE ALSO SJA1000 Product Specification Manual 6 4 3 MODE REGISTER MOD TIP810 SW 82 Linux Device Driver Page 26 of 37 TEWS amp TECHNOLOGIES 3 5 5 T810_IOCFLUSH NAME T810_IOCFLUSH Flush the received message FIFO DESCRIPTION This ioctl function flushes the FIFO buffer of received messages The optional argument pointer can be omitted for this ioctl function EXAMPLE include lt tip810 h gt int Si int result result ioctl fd T810_IOCFLUSH if result lt 0 handle ioctl error ERRORS This ioctl function returns no function specific error codes TIP810 SW 82 Linux Device Driver Page 27 of 37 TEWS amp TECHNOLOGIES 3 5 6 T810
19. ice Driver Page 31 of 37 TEWS amp TECHNOLOGIES 3 5 9 T810_ IOCENABLE_ LISTENONLY NAME T810_IOCENABLE_LISTENONLY Enable listen only mode DESCRIPTION This ioctl function enables the listen only facility of the SJA1000 CAN controller In this mode the CAN controller would give no acknowledge to the CAN bus even if a message is received successfully Message transmission is not possible All other functions can be used like in normal mode This mode can be used for software driver bit rate detection and hot plugging The optional argument pointer can be omitted for this ioctl function This ioctl command will be accepted only in reset mode BUSOFF Enter T810_ IOCBUSOFF first otherwise you will get an error EACCES EXAMPLE include lt tip810 h gt int fd int result result ioctl fd T810_IOCENABLE LISTENONLY if result lt 0 handle ioctl error ERRORS EACCES The CAN controller is in operating mode This mode can be changed only in reset mode SEE ALSO SJA1000 Product Specification Manual 6 4 3 MODE REGISTER MOD TIP810 SW 82 Linux Device Driver Page 32 of 37 TEWS amp TECHNOLOGIES 3 5 10 T810_ IOCDISABLE_LISTENONLY NAME T810_IOCDISABLE_LISTENONLY Disable listen only mode DESCRIPTION This ioctl function disables the listen only facility of the SJA1000 CAN controller which was before enabled with the ioctl command T810_IOCENABL
20. is in operating mode This mode can be changed only in reset mode EFAULT An error occurred during memory data transfer between kernel and user space SEE ALSO SJA1000 Product Specification Manual 6 4 3 MODE REGISTER MOD TIP810 SW 82 Linux Device Driver Page 34 of 37 TEWS amp TECHNOLOGIES 3 6 Step by Step Driver Initialization The following code example illustrates all necessary steps to initialize a CAN device for communication x ER 1 Setup CAN bus bit timing WI BitTimingParam TimingValue T810_100KBIT BitTimingParam ThreeSamples FALSE result ioctl fd T810_IOCSBITTIMING char amp BitTimingParam xx 2 Setup acceptance filter masks AcceptFilter AcceptanceCode 0x0 AcceptFilter AcceptanceMask OxFFFFFFFF AcceptFilter SingleFilter 1 result ioctl fd T810_IOCSSETFILTER char amp AcceptFilter ER 3 Enter Bus On State result ioctl fd T810_IOCBUSON Now you should be able to send and receive CAN messages with appropriate calls to write and read functions TIP810 SW 82 Linux Device Driver Page 35 of 37 4 Debugging TEWS amp TECHNOLOGIES For debugging output see driver file tip810 c You will find the two following symbols undef TIP810_D undef TIP810_D To enable a debug output replace undef with define EBUG_INTR EBUG_VIEW The TIP810_DEB
21. man pages TIP810 SW 82 Linux Device Driver Page 20 of 37 TEWS amp TECHNOLOGIES 3 5 1 T810_IOCSBITTIMING NAME T810_IOCSBITTIMING Setup new bit timing DESCRIPTION This ioctl function modifies the bit timing register of the CAN controller to setup a new CAN bus transfer speed A pointer to the caller s parameter buffer 7870_TIMING is passed by the argument pointer arg to the driver Keep in mind to setup a valid bit timing value before changing into the Bus On state typedef struct unsigned short TimingValue unsigned short ThreeSamples T810_TIMING PT810_TIMING Timing Value This parameter holds the new value for the bit timing register 0 bit 0 7 and for the bit timing register 1 bit 8 15 Possible transfer rates are between 5 Kbit per second and 1 Mbit per second The include file tip810 h contains predefined transfer rate symbols T810_5KBIT T810_1MBIT For other transfer rates please follow the instructions of the SJA1000 Product Specification which is also part of the engineering kit TIP810 EK ThreeSamples If this parameter is TRUE 1 the CAN bus is sampled three times per bit time instead of one Use one sample point for faster bit rates and three sample points for slower bit rates to make the CAN bus more immune against noise spikes TIP810 SW 82 Linux Device Driver Page 21 of 37 TEWS amp TECHNOLOGIES EXAMPLE include lt tip810 h gt int fd
22. nction This ioctl command will be accepted only in reset mode BUSOFF Enter T810_ IOCBUSOFF first otherwise you will get an error EACCES EXAMPLE include lt tip810 h gt int fd int result result ioctl fd T810_IOCENABLE SELFTEST if result lt 0 handle ioctl error ERRORS EACCES The CAN controller is in operating mode This mode can be changed only in reset mode SEE ALSO SJA1000 Product Specification Manual 6 4 3 MODE REGISTER MOD TIP810 SW 82 Linux Device Driver Page 30 of 37 TEWS amp TECHNOLOGIES 3 5 8 T810_ IOCDISABLE_SELFTEST NAME T810_ IOCDISABLE SELFTEST Disable self test mode DESCRIPTION This ioctl function disables the self test facility of the SJA1000 CAN controller which was before enabled with the ioctl command T810_IOCENABLE_ SELFTEST The optional argument pointer can be omitted for this function This ioctl command will be accepted only in reset mode BUSOFF Enter T810_ IOCBUSOFF first otherwise you will get an error EACCES EXAMPLE include lt tip810 h gt int fd int result result ioctl fd T810_IOCDISABLE SELFTEST if result lt 0 handle ioctl error ERRORS EACCES The CAN controller is in operating mode This mode can be changed only in reset mode SEE ALSO SJA1000 Product Specification Manual 6 4 3 MODE REGISTER MOD TIP810 SW 82 Linux Dev
23. oo small for the application read interval T810_MSGOBJ_OVERRUN One or more messages were overwritten in the CAN controller message object because the interrupt latency is too large Reduce the CAN bit rate or upgrade the system speed EXAMPLE include lt tip810 h gt int fa ssize_t numBytes T810_MSG_BUF msgBuf msgBuf Timeout 200 numBytes read fd amp msgBuf sizeof msgBuf if mumBytes gt 0 process received CAN message RETURNS On success read returns the size of structure T810_ MSG_BUF In the case of an error a value of 1 is returned The global variable errno contains the detailed error code TIP810 SW 82 Linux Device Driver Page 14 of 37 ERRORS EINVAL EFAULT ECONNREFUSED EAGAIN ETIME EINTR SEE ALSO TEWS amp TECHNOLOGIES Invalid argument This error code is returned if the size of the message buffer is too small Invalid pointer to the message buffer The controller is in bus off state and no message is available in the driver receive queue Note as long as CAN messages are available in the receive queue FIFO bus off conditions were not reported by a read function This means you can read all CAN messages out of the receive queue FIFO during bus off state without an error result Resource temporarily unavailable the call might work if you try again later This error occurs only if the device is opened with the flag O_NONBLOCK set The allowed
24. pointer arg to the driver typedef struct int SingleFilter unsigned long AcceptanceCode unsigned long AcceptanceMask T810_FILTER PT810_FILTER SingleFilter Set TRUE 1 for single filter mode Set FALSE 0 for dual filter mode AcceptanceCode The contents of this parameter will be written to acceptance code register of the controller This value must be shifted to match the desired identifier refer to SJA1000 manual AcceptanceMask The contents of this parameter will be written to the acceptance mask register of the controller This value must be shifted to match the desired identifier refer to SJA1000 manual A detailed description of the acceptance filter and possible filter modes can be found in the SJA1000 Product Specification Manual TIP810 SW 82 Linux Device Driver Page 23 of 37 TEWS amp TECHNOLOGIES EXAMPLE include lt tip810 h gt int fd int result T810_FILTER AcceptFilter Not relevant because all bits are don t care AcceptFilter AcceptanceCode 0x0 Mark all bit position don t care AcceptFilter AcceptanceMask Oxffffffff Single Filter Mode AcceptFilter SingleFilter 1 TRUE result ioctl fd T810_IOCSSETFILTER char amp AcceptFilter if result lt 0 handle ioctl error ERRORS EACCES The CAN controller is in operating mode This mode can be changed only in reset mode EF
25. ration Received CAN messages will be stored in a FIFO buffer The depth of the FIFO can be adapted by changing the following symbol in tip81Odef h T810_RX_FIFO_ SIZE Defines the depth of the message FIFO buffer default 100 Valid numbers are in range between 1 and MAXINT TIP810 SW 82 Linux Device Driver Page 9 of 37 TEWS amp TECHNOLOGIES 3 Device Input Output functions This chapter describes the interface to the device driver I O system used for communication over the CAN Bus 3 1 open NAME open open a file descriptor SYNOPSIS include lt fcntl h gt int open const char filename int flags DESCRIPTION The open function creates and returns a new file descriptor for the file named by filename The flags argument controls how the file is to be opened This is a bit mask you create the value by the bitwise OR of the appropriate parameters using the operator in C See also the GNU C Library documentation for more information about the open function and open flags EXAMPLE int fd fd open dev tip810_0 O_RDWR if fd 1 handle error condition RETURNS The normal return value from open is a non negative integer file descriptor In the case of an error a value of 1 is returned The global variable errno contains the detailed error code TIP810 SW 82 Linux Device Driver Page 10 of 37 TEWS amp TECHNOLOGIES ERRORS ENODEV The requested minor device
26. s set will be transmitted No re transmission will be performed if an error occurred or the arbitration will be lost during transmission single shot transmission The message will be transmitted and simultaneously received if the acceptance filter is set to the corresponding identifier Page 16 of 37 TEWS amp TECHNOLOGIES MsgLen Contains the number of message data bytes 0 8 Data This buffer contains up to 8 data bytes Data 0 contains message Data 0 Data 1 contains message Data 1 and so on Timeout Specifies the amount of time in ticks the caller is willing to wait for execution of write Status This parameter is unused for this control function EXAMPLE include lt tip810 h gt int fd int result T810_MSG_BUF msgBuf Write two data bytes with extended identifier 1234 to xx the CANbus and wait max 200 ticks on execution The transmitted frame will be received simultaneously msgBuf Identifier 1234 msgBuf Timeout 200 msgBuf IOFlags T810_EXTENDED T810_SELF_RECEPTION msgBuf MsgLen 2 msgBuf Data 0 Oxaa msgBuf Data 1 0x55 result write fd amp msgBuf sizeof msgBuf if result sizeof T810_MSG_BUF printf nWrite failed gt Error d n errno TIP810 SW 82 Linux Device Driver Page 17 of 37 RETURNS TEWS amp TECHNOLOGIES On success write returns the size of structure T810_ M
27. t up to 1 Mbit and user defined bit rates Message acceptance filtering Single Shot transmission Listen only mode Message self reception Programmable error warning limit VVVVVVV The TIP810 SW 82 supports the modules listed below TIP810 10 1 Channel CAN Bus IndustryPack To get more information about the features and use of the supported devices it is recommended to read the manuals listed below TIP810 User manual TIP810 Engineering Manual SJA1000 PeliCAN controller User Manual CARRIER SW 82 IPAC Carrier User Manual TIP810 SW 82 Linux Device Driver Page 4 of 37 TEWS amp TECHNOLOGIES 1 2 IPAC Carrier Driver IndustryPack IPAC carrier boards have different implementations of the system to IndustryPack bus bridge logic different implementations of interrupt and error handling and so on Also the different byte ordering big endian versus little endian of CPU boards will cause problems on accessing the IndustryPack I O and memory spaces To simplify the implementation of IPAC device drivers which work with any supported carrier board TEWS TECHNOLOGIES has designed a so called Carrier Driver that hides all differences of different carrier boards under a well defined interface The TEWS TECHNOLOGIES IPAC Carrier Driver CARRIER SW 82 is part of this TIP810 SW 82 distribution It is located in directory CARRIER SW 82 on the corresponding distribution media This IPAC Device Driver requires a properly installed IPA
28. the driver receive queue A pointer to the callers message buffer 7810_MSG_BUF and the size of this structure are passed by the parameters buffer and size to the device typedef struct unsigned long unsigned char unsigned char unsigned char long unsigned char T810_MSG_BUF PT810_MS Identifier Identifier IOFlags MsgLen Data 8 Timeout Status G_BUF Receives the message identifier of the read CAN message IOFlags Receives CAN message attributes as a set of bit flags The following attribute flags are possible T810_EXTENDED T810_REMOTE_FRAME TIP810 SW 82 Linux Device Driver Set if the received message is an extended message frame Reset for standard message frames Set if the received message is a remote transmission request RTR frame Page 13 of 37 TEWS amp TECHNOLOGIES MsgLen Receives the number of message data bytes 0 8 Data This buffer receives up to 8 data bytes Data 0 receives message Data 0 Data 1 receives message Data 1 and so on Timeout Specifies the amount of time in ticks the caller is willing to wait for execution of read A value of 0 means wait indefinitely Status This parameter receives status information about overrun conditions either in the CAN controller or intermediate software FIFO T810_ SUCCESS No messages lost T810_FIFO_OVERRUN One or more messages ware overwritten in the receive queue FIFO This problem occurs if the FIFO is t
29. time to finish the read request has elapsed Interrupted function call an asynchronous signal occurred and prevented completion of the call When this happens you should try the call again GNU C Library description Low Level Input Output TIP810 SW 82 Linux Device Driver Page 15 of 37 3 4 write NAME write write to a device SYNOPSIS include lt unistd h gt ssize_t write int filedes void buffer size_t size DESCRIPTION TEWS amp TECHNOLOGIES The write function writes a CAN message to the device with descriptor filedes A pointer to the callers message buffer 7810_MSG_BUF and the size of this structure are passed by the parameters buffer and size to the device typedef struct unsigned long Identifier unsigned char IOFlags unsigned char MsgLen unsigned char Data 8 long Timeout unsigned char Status T810_MSG_BUF PT810_MSG_BUF Identifier Contains the message identifier of the CAN message to write IOFLags Contains a set of bit flags which define message attributes and controls the write operation To set more that one bit flag the predefined macros must be binary ORed T810_EXTENDED T810_REMOTE_FRAME T810_SINGLE_SHOT T810_SELF_RECEPTION TIP810 SW 82 Linux Device Driver Transmit an extended message frame If this macro isn t set or the dummy macro T810_STANDARD is set a standard frame will be transmitted A remote transmission request RTR bit i
30. tion The optional argument argp depends on the selected request and is described for each request in detail later in this chapter The following ioctl codes are defined in tip810 h Symbol T810_IOCSBITTIMING T810_IOCSSETFILTER T810_IOCBUSON T810_IOCBUSOFF T810_IOCFLUSH T810_IOCGCANSTATUS T810_lIOCENABLE_SELFTEST T810_lIOCDISABLE_SELFTEST T810_IOCENABLE_LISTENONLY T810_IOCDISABLE_LISTENONLY T810_lIOCSSETLIMIT Meaning Setup a new bit timing Setup acceptance filter Enter the bus on state Enter the bus off state Flush one or all receive queues Returns CAN controller status information Enable self test mode Disable self test mode Enable listen only mode Disable listen only mode Set new error warning limit See behind for more detailed information on each control code To use these TIP810 specific control codes the header file tip810 h must be included in the application TIP810 SW 82 Linux Device Driver Page 19 of 37 TEWS amp TECHNOLOGIES RETURNS On success zero is returned In the case of an error a value of 1 is returned The global variable errno contains the detailed error code ERRORS EINVAL Invalid argument This error code is returned if the requested ioctl function is unknown Please check the argument request Other function dependant error codes will be described for each ioctl code separately Note the TIP810 driver always returns standard Linux error codes SEE ALSO ioctl

Download Pdf Manuals

image

Related Search

Related Contents

Epson PowerLite Home 10 Product Brochure  Manual do Usuário Coifa GE Modelo COGE090LPA2VD  Page 4  GB Operating Instructions Hanging scale  Samsung LE40C679M1S Manual de Usuario  Operating instructions  Tabla de contenido  POLI VAC User Manual  Manual de usuario turboTEC classic bajo NOx Manual de  Taylor QS22 Electric Grill User Manual  

Copyright © All rights reserved.
Failed to retrieve file