解決Android裝置插入印表機無法啟動

來源:互聯網
上載者:User

一直在想起一個什麼題目好一些,題目只是最初的現實,經過不斷調試最後很是其它問題,想要起一個其它名字比如《印表機驅動中熱插拔事件中添加DEVTYPE》。但是最後想了想還是回到最初才是好的。  具體現象:源碼位置NativeDaemonConnector.java(查看VOLD的TAG)02-10 01:21:02.340: E/VoldConnector(11051): got -1 reading with start = 002-10 01:21:02.340: E/VoldConnector(11051): closing stream for vold02-10 01:21:02.340: E/VoldConnector(11051): Communications error: java.io.IOException: No such file or directory02-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群主。一步步指點著添加成功了。如:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.