📄 canbuscore.c
字号:
/* * canbuscore.c * Copyright (c) 2001 J黵gen Eder <Juergen.Eder@gmx.de> * * A general canbus driver. To use this, you need also a * hardware driver (for example: sja1000.o + can200par.o). * Tested under Linux 2.4.20 on i386 PC architecture. * * installation: * * make all * make install * * char-major numbers up to 240 are "LOCAL/EXPERIMENTAL" (see /usr/src/linux/Documentation/devices.txt) * char-major 91 is reserved for CAN BUS * insert following lines into /etc/modules.conf: * * only ELEKTOR CAN Card * -------------------------------------------------- * alias char-major-91 elektor_canpar * * * or only CAN200 Card * -------------------------------------------------- * alias char-major-91 can200par * * * or both CAN Cards (kernel < 2.4.0) * -------------------------------------------------- * alias char-major-91 elektor_canpar * post-install elektor_canpar /sbin/modprobe "-k" can200par * * * or both CAN Cards (kernel >= 2.4.0, this also work with 2.2.x) * -------------------------------------------------- * alias char-major-91 canbus * probeall canbus elektor_canpar can200par * -------------------------------------------------- * * Also set the IRQ for the parport driver * for example (IRQ 7 for LPT1): * -------------------------------------------------- * options parport_pc io=0x378 irq=7,none * -------------------------------------------------- * * After changing "modules.conf" do a "depmod -a" * * Kernel > 2.5 need a "generate-modprobe.conf" * * Reload the parport driver: * rmmod parport_pc * modprobe parport_pc io=0x378 irq=7 * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of 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 of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#define EXPORT_SYMTAB#define CANBUS4LINUX_CLEARTEXT_COMMANDS#include <linux/version.h>#include <linux/module.h>#include <linux/slab.h>#include <linux/parport.h>#include <linux/ioctl.h>#include <asm/uaccess.h>#include <linux/poll.h>#include <linux/proc_fs.h>#include <linux/delay.h>#include <linux/time.h>#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,67)#include <linux/fs.h>#include <linux/kdev_t.h>#endif#include "trace.h"#include "canbus4linux.h"#ifdef MODULE_LICENSEMODULE_LICENSE("GPL");#endifstatic int major=91;static int virtualize=1;static char *version = "0.2.1";#define CANBUS4LINUX_PROC_DIR "canbus"#define NUM_CANBUS_DEVICES 10#define MAX_DEVICE_INFO (2*MAX_DEVICE_NAME_LENGTH)#define NUMBER_OF_WRITE_BUFFER (100)#define MAX_EVENTS (2*NUMBER_OF_WRITE_BUFFER)int canbus4linux_fasync(int fd, struct file *file, int mode);void *Allocate_Memory(unsigned long s);void Free_Memory(void *p);struct canbus_time GetTime(void);static struct canbus_admin canbus4linux_admin[NUM_CANBUS_DEVICES];static struct proc_dir_entry *canbus4linux_proc_dir=NULL;struct canbus_intern_transmit { struct canbus_transmit_data data; struct file *fa_file;};struct proc_registers{ struct canbus_admin *pAdmin; u16 register_nr;};struct canbus_file;struct canbus_admin{ /* W I C H T I G * Bei 膎derungen mu
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -