• PUDN用户
    了解作者
  • Unix_Linux
    开发工具
  • 7KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 27
    下载次数
  • 2005-09-27 02:36
    上传日期
usb接口的scanner的驱动,稍加修改就可以使用了. 测试过了,可以使用
usbdrv_8.rar
  • usbdrv.c
    24.5KB
  • www.pudn.com.txt
    218B
内容介绍
/*************************************************************************** usbdrv.cpp - description ------------------- begin : 五 9月 9 2005 copyright : (C) 2005 by root email : root@localhost.localdomain ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #define __KERNEL__ #define MODULE #include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h> #include <asm/uaccess.h rel='nofollow' onclick='return false;'> #include <linux/init.h> #include <linux/slab.h> #include <linux/delay.h> #include <linux/ioctl.h> #include <linux/fs.h> #include <linux/sched.h> #include <linux/smp_lock.h> #include <linux/devfs_fs_kernel.h> #include <linux/config.h> #include <linux/mm.h> #include <linux/slab.h> //#include <linux/devfs_fs_kernel.h> #include <linux/version.h> #include <linux/usb.h> //#define DEBUG //#ifdef DEBUG #define db printk //#define warn printk // #define err printk //#else //#define db dbg //#endif #define USB_SN_VENDOR_ID 0x7890 #define USB_SN_PRODUCT_ID 0x0002 /* Get a minor range for your devices from the usb maintainer */ #define SCN_BASE_MNR 128 /* we can have up to this number of device plugged in at once */ #define MAX_DEVICES 16 #define IBUF_SIZE 16384*2 //32768 #define OBUF_SIZE 4096 #define CMD_READ_STATE 6 #define CMD_READ_DATA 8 #define IS_EP_BULK(ep) ((ep).bmAttributes == USB_ENDPOINT_XFER_BULK ? 1 : 0) #define IS_EP_BULK_IN(ep) (IS_EP_BULK(ep) && ((ep).bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) #define IS_EP_BULK_OUT(ep) (IS_EP_BULK(ep) && ((ep).bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) #define IS_EP_INTR(ep) ((ep).bmAttributes == USB_ENDPOINT_XFER_INT ? 1 : 0) #define USB_SN_MINOR(X) MINOR((X)->i_rdev) - SCN_BASE_MNR #define SNUSB_IOCTL_READ_STATUS _IOWR('U', 0x26, void*) #define SNUSB_IOCTL_USER_CODE _IOWR('U', 0x27, void*) #define ENDPOINT_IN 0x2 #define ENDPOINT_OUT 0x0 #define ENDPOINT_INIR 0x1 //#define COMPANY "SinoData" //#define DESCRIPTION "SinoData Usb Linux Driver by HP" MODULE_AUTHOR("SinoData"); MODULE_DESCRIPTION("SinoData Usb Linux Driver by HP"); MODULE_LICENSE("GPL"); int ibuf_size=IBUF_SIZE; struct scn_usb_data { struct usb_device *scn_dev; devfs_handle_t devfs; /* devfs device */ struct usb_interface* interface; struct urb* write_urb; unsigned int ifnum; /* Interface number of the USB device */ kdev_t scn_minor; /* sn minor - used in disconnect() */ unsigned char button; /* Front panel buffer */ char isopen; /* Not zero if the device is open */ char present; /* Not zero if device is present */ char *bulk_out_buffer; char *bulk_in_buffer; /* transfer buffers */ char bulk_in_ep; char bulk_out_ep; char intr_ep; /* Endpoint assignments */ int bulk_in_size; int bulk_out_size; int open_count; wait_queue_head_t rd_wait_q; /* read timeouts */ struct semaphore sem; /* lock to prevent concurrent reads or writes */ unsigned int rd_nak_timeout; /* Seconds to wait before read() timeout. */ }; /* the global usb devfs handle */ extern devfs_handle_t usb_devfs_handle; static struct scn_usb_data *minor_table[MAX_DEVICES]; /* lock to protect the minor_table structure */ static DECLARE_MUTEX (minor_table_mutex); static struct usb_device_id sn_table [] = { //{USB_DEVICE(0x7890,0x0002)}, {USB_DEVICE(USB_SN_VENDOR_ID, USB_SN_PRODUCT_ID)}, {} }; MODULE_DEVICE_TABLE (usb, sn_table); ////////////////////////----------------------------------------------------------------- static void usb_show_endpoint(struct usb_endpoint_descriptor *endpoint) /* [<][>][^][v][top][bottom][index][help] */ { usb_show_endpoint_descriptor(endpoint); } static void usb_show_interface(struct usb_interface_descriptor *altsetting) /* [<][>][^][v][top][bottom][index][help] */ { int i; usb_show_interface_descriptor(altsetting); for (i = 0; i < altsetting->bNumEndpoints; i++) usb_show_endpoint(altsetting->endpoint + i); } static void usb_show_config(struct usb_config_descriptor *config) /* [<][>][^][v][top][bottom][index][help] */ { int i, j; struct usb_interface *ifp; usb_show_config_descriptor(config); for (i = 0; i < config->bNumInterfaces; i++) { ifp = config->interface + i; if (!ifp) break; printk("\n Interface: %d\n", i); for (j = 0; j < ifp->num_altsetting; j++) usb_show_interface(ifp->altsetting + j); } } void usb_show_device(struct usb_device *dev) /* [<][>][^][v][top][bottom][index][help] */ { int i; usb_show_device_descriptor(&dev->descriptor); for (i = 0; i < dev->descriptor.bNumConfigurations; i++) usb_show_config(dev->config + i); } /* * Parse and show the different USB descriptors. */ void usb_show_device_descriptor(struct usb_device_descriptor *desc) /* [<][>][^][v][top][bottom][index][help] */ { if (!desc) { db("Invalid USB device descriptor (NULL POINTER)\n"); return; } db(" Length = %2d%s\n", desc->bLength, desc->bLength == USB_DT_DEVICE_SIZE ? "" : " (!!!)"); db(" DescriptorType = %02x\n", desc->bDescriptorType); db(" USB version = %x.%02x\n", desc->bcdUSB >> 8, desc->bcdUSB & 0xff); db(" Vendor:Product = %04x:%04x\n", desc->idVendor, desc->idProduct); db(" MaxPacketSize0 = %d\n", desc->bMaxPacketSize0); db(" NumConfigurations = %d\n", desc->bNumConfigurations); db(" Device version = %x.%02x\n", desc->bcdDevice >> 8, desc->bcdDevice & 0xff); db(" Device Class:SubClass:Protocol = %02x:%02x:%02x\n", desc->bDeviceClass, desc->bDeviceSubClass, desc->bDeviceProtocol); switch (desc->bDeviceClass) { case 0: db(" Per-interface classes\n"); break; case USB_CLASS_AUDIO: db(" Audio device class\n"); break; case USB_CLASS_COMM: db(" Communications class\n"); break; case USB_CLASS_HID: db(" Human Interface Devices class\n"); break; case USB_CLASS_PRINTER: db(" Printer device class\n"); break; case USB_CLASS_MASS_STORAGE: db(" Mass Storage device class\n"); break; case USB_CLASS_HUB: db(" Hub device class\n"); break; case USB_CLASS_VENDOR_SPEC: db(" Vendor class\n"); break; default: db(" Unknown class\n"); } } void usb_show_config_descriptor(struct usb_config_descriptor *desc) /* [<][>][^][v][top][bottom][index][help] */ { db("Configuration:\n"); db(" bLength = %4d%s\n", desc->bLength, desc->bLength == USB_DT_CONFIG_SIZE ? "" : " (!!!)"); db(" bDescriptorType = %02x\n", desc->bDescriptorType); db(" wTotalLength = %04x\n", desc->wTotalLength); db(" bNumInter
评论
    相关推荐
    • 霍尼韦尔honeywell1900 USB驱动程序
      霍尼韦尔honeywell1900扫描枪的USB驱动,就是扫描枪usb转com。安装说明:解压后再安装,如果你的系统是32位的,就直接运行Install_x86.bat,如果是64位的,就运行Install_x64.bat。驱动文件:acmfccoi_21617....
    • 扫码枪驱动1900
      honeywell 驱动,保证扫码枪的正常使用 HONEYWELL 1900GHD扫描器的数据格式编辑器说明都有哪些?下面扫描网来为您解答: 以下是用于输入HONEYWELL 1900GHD扫描器数据格式的简要说明: 扫描器扫描“输入数据格式”...
    • 驱动开发工具包
      包含EzDriverInstaller、WinObj、DriverMonitor、devicetree和DebugView
    • 理光Aficio SP C242SF一体机USB TWAIN扫描驱动 v1.04 官方版
      理光AficioSPC242SF一体机USBTWAIN扫描驱动是一款帮助扫描机快速稳定运行的驱动软件,利用这款驱动不仅能节约成本,减少浪费,还能提高传真扫描的效率,还能与他人共享,功能多多而且实用,有需求的用户就下载使用吧...
    • LSI 3081 驱动
      2003驱动使用 使用软驱加载驱动 按F6使用加载Windows驱动
    • Barcode-Scanner-master.zip
      下载 2.4G 或 433 Scanner 安卓SDK SDK 和示例在蓝牙无线扫描器中工作,它演示了如何在 Android 设备中为条码扫描器编码。 样本中的特征: 自动连接到蓝牙条码扫描器 通过 SPP 获取条码编号 计算输入的总数 该...
    • 安卓串口Socket通讯USB驱动jni相关-AndroidScanner扫描目标设备可用端口的小程序.rar
      Android Scanner扫描目标设备可用端口的小程序.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
    • 驱动开发必备工具,Device Tree V2.3,完美支持Win7
      在国外站淘回来的,驱动开发必备工具,完美支持Win7
    • linux下USB驱动Sample代码
      这个驱动是写在用户空间的, 不涉及内核的重新编译,就可以控制USB设备, 利用了libusb1.0 实现了类似于lsusb指令的功能
    • 民德扫描器_USB虚拟串口驱动.rar
      安装包vb6企业版安装包,需要的小伙伴快下载吧