?? readme
字號:
This is version 0.2 of my driver for a simple CAN bus interface.2000 03 25Copyright (c) 2000 Martin Homuth-Rosemann <homuth-rosemann@gmx.net>This program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to theFree Software Foundation, Inc.,59 Temple Place - Suite 330,Boston, MA 02111-1307, USA.Hardware========The interface consists of a CAN controller Philips 82C200(or its successor SJA100) and a CAN bus interfacePhilips 82C250 or 82C251. Very little glue electronic allowsthe connection to an EPP printer port. The schematics "can200.png"are included in this driver tarball. In EPP mode the port speed(reading and writing) is about 500 kByte/s. So it is possibleto transfer at CAN bitrates up to 1 Mbit/s.For low speed applications (up to 125 kbit/s) the driver cancompiled for PS/2 (bidirectional) parallel ports found on someolder PCs. The driver emulates the EPP protocoll in softwareat a speed of about 100 kByte/s.The interface and driver were tested under Linux kernelversion 2.2.14 on a i386 PC architecture. Care was takento be compatible to kernel versions 2.0.xx.Installing the Driver=====================Type make to build the driver "can200.o",the device descriptors "can20k" and "can40k" andthe test program "can_test". make loadinserts the driver module, make teststarts a test program.If there is no other CAN device connected to the interfacethe test program returns with Input/output error.The driver uses major = 60. The minor numbers select the speed: Minor Speed ----------------- 0 10kbit/s 1 20kbit/s 2 40kbit/s 3 50kbit/s 4 100kbit/s 5 125kbit/sProgramming Interface=====================The can device driver transfers can messages to or from user programsin fixed size 20 byte blocks.The first 13 bytes show the layout of the SJA100 TX and RX buffer.Received frames contain pad, status and timestamp field. These fields areignored on transmit. ------+-------+------------------------------------------------ Addr. I Field I bit8 bit6 bit5 bit4 bit3 bit2 bit1 bit0 ------+-------+------------------------------------------------ 0 I info I EFF RTR 0 0 DLC.3 DLC.2 DLC.1 DLC.0 1 I id0 I ID.28 ID.27 ID.26 ID.25 ID.24 ID.23 ID.22 ID.21 EFF=0: 2 I id1 I ID.20 ID.19 ID.18 RTR 0 0 0 0 EFF=1: 2 I id1 I ID.20 ID.19 ID.18 ID.17 ID.16 ID.15 ID.14 ID.13 " 3 I id2 I ID.12 ID.11 ID.10 ID.9 ID.8 ID.7 ID.6 ID.5 " 4 I id3 I ID.4 ID.3 ID.2 ID.1 ID.0 RTR 0 0 5 I data0 I Data byte 1 6 I data1 I Data byte 2 7 I data2 I Data byte 3 8 I data3 I Data byte 4 9 I data4 I Data byte 5 10 I data5 I Data byte 6 11 I data6 I Data byte 7 12 I date7 I Data byte 8 ------+-------+------------------------------------------------ 13 pad unsigned char pad, incremented on every receive 14-15 status unsigned short status, 0 = ok. (TBD) 16-20 time- unsigned long timestamp ( jiffies ) stamp ------+-------+------------------------------------------------ Unused data bytes are ignored on transmit, in received frames zero is returned.This example shows the programming of the can interface: #include "can200.h" ... int can; can_msg_t msg; can = open( "/dev/can20k", O_RDWR ); if ( can >= 0 ) { /* open ok */ while ( CAN_MSG_LEN == read( can, &msg, CAN_MSG_LEN ) ) { /* we got a message, do something ... */ ... if (...) /* end of processing... */ break; } close( can ); } ... The can device operates also in nonblocking mode: ... can = open( "/dev/can20k", O_RDWR | O_NONBLOCK ); if ( can >= 0 ) { /* open ok */ sleep( 2 ); while ( CAN_MSG_LEN == read( can, msg, CAN_MSG_LEN ) ) { /* process all messages already received */ /* leave the loop if no mor msg */ ... } close( can ); }You can switch between the two mode with the fcntl call: ... fcntl( can, F_SETFL, 0 ); /* blocking mode */ ... fcntl( can, F_SETFL, O_NONBLOCK ); /* nonblocking mode */ ...The homepage of the can200 project is located at:http://private.addcom.de/horo/can200/index.html
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -