解决Android设备插入打印机无法启动

来源:互联网 发布:嵌入式用什么软件 编辑:程序博客网 时间:2024/04/30 03:57
  一直在想起一个什么题目好一些,题目只是最初的现实,经过不断调试最后很是其它问题,想要起一个其它名字比如《打印机驱动中热插拔事件中添加DEVTYPE》。但是最后想了想还是回到最初才是好的。
  具体现象:源码位置NativeDaemonConnector.java(查看VOLD的TAG)
02-10 01:21:02.340: E/VoldConnector(11051): got -1 reading with start = 0
02-10 01:21:02.340: E/VoldConnector(11051): closing stream for vold
02-10 01:21:02.340: E/VoldConnector(11051): Communications error: java.io.IOException: No such file or directory
02-10 01:21:02.340: E/VoldConnector(11051): Error in NativeDaemonConnector: java.io.IOException: No such file or directory
  分析:在不做任何程序上的修改的情况下,插入USB无线网卡是没有问题的。目前打印机和无线网卡都是没有上报信息的,这就排除了上报消息的原因了。目前的区别是DEVTYPE,前者是无,后者是有的。
  
  查看所有error时找出了问题所在:
  NetlinkEvent::FindParam(): Parameter 'DEVTYPE' not found
  果真是之前的假设问题,在获取DEVTYPE时出的问题

  以下就是如何在内核的usb打印机驱动中添加DEVTYPE的问题,花费了一下午的时间以下的diff文件:
diff --git a/kernel/drivers/usb/class/usblp.c b/kernel/drivers/usb/clindex 9eca405..b528437 100755--- a/kernel/drivers/usb/class/usblp.c+++ b/kernel/drivers/usb/class/usblp.c@@ -1046,8 +1046,13 @@ static const struct file_operations usblp_fops        .llseek =       noop_llseek, }; +static struct device_type printer_type = {+       .name   = "printer",+};+ static char *usblp_devnode(struct device *dev, mode_t *mode) {+       dev->type=&printer_type;        return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev)); } @@ -1072,6 +1077,7 @@ static ssize_t usblp_show_ieee1284_id(struct de  static DEVICE_ATTR(ieee1284_id, S_IRUGO, usblp_show_ieee1284_id, NUL + static int usblp_probe(struct usb_interface *intf,                       const struct usb_device_id *id) {@@ -1079,6 +1085,8 @@ static int usblp_probe(struct usb_interface *in        struct usblp *usblp;        int protocol;        int retval;+       //dev->children[0]->dev.type=&printer_type;+       //dev->dev.type=&printer_type;         /* Malloc and start initializing usblp structure so we can us         * directly. */
      注:注释的那两条是测试的过但是不成功的方法

      这里点名感谢一下《Linux驱动》群中的LinuxDrv群主。一步步指点着添加成功了。如下图:


1 0
原创粉丝点击