{"action":"created","issue":{"url":"https://api.github.com/repos/pyusb/pyusb/issues/207","repository_url":"https://api.github.com/repos/pyusb/pyusb","labels_url":"https://api.github.com/repos/pyusb/pyusb/issues/207/labels{/name}","comments_url":"https://api.github.com/repos/pyusb/pyusb/issues/207/comments","events_url":"https://api.github.com/repos/pyusb/pyusb/issues/207/events","html_url":"https://github.com/pyusb/pyusb/issues/207","id":347370631,"node_id":"MDU6SXNzdWUzNDczNzA2MzE=","number":207,"title":"usb.core.USBError: [Errno 32] Pipe error","user":{"login":"ysharshit","id":34596903,"node_id":"MDQ6VXNlcjM0NTk2OTAz","avatar_url":"https://avatars1.githubusercontent.com/u/34596903?v=4","gravatar_id":"","url":"https://api.github.com/users/ysharshit","html_url":"https://github.com/ysharshit","followers_url":"https://api.github.com/users/ysharshit/followers","following_url":"https://api.github.com/users/ysharshit/following{/other_user}","gists_url":"https://api.github.com/users/ysharshit/gists{/gist_id}","starred_url":"https://api.github.com/users/ysharshit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ysharshit/subscriptions","organizations_url":"https://api.github.com/users/ysharshit/orgs","repos_url":"https://api.github.com/users/ysharshit/repos","events_url":"https://api.github.com/users/ysharshit/events{/privacy}","received_events_url":"https://api.github.com/users/ysharshit/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-08-03T12:04:35Z","updated_at":"2018-08-07T01:09:07Z","closed_at":null,"author_association":"NONE","body":"I am trying to read/write using a USB-OTG port in Altera De0 Nano SoC. I have the Atlas SoC installed in a SD card for using the Arm Linux.\r\nThe Descriptors of the device are as follows:\r\nCONFIGURATION 1: 2 mA ====================================\r\n   bLength              :    0x9 (9 bytes)\r\n   bDescriptorType      :    0x2 Configuration\r\n   wTotalLength         :   0xa4 (164 bytes)\r\n   bNumInterfaces       :    0x5\r\n   bConfigurationValue  :    0x1\r\n   iConfiguration       :    0x6 Multifunction with RNDIS\r\n   bmAttributes         :   0xc0 Self Powered\r\n   bMaxPower            :    0x1 (2 mA)\r\n    INTERFACE 0: CDC Communication =========================\r\n     bLength            :    0x9 (9 bytes)\r\n     bDescriptorType    :    0x4 Interface\r\n     bInterfaceNumber   :    0x0\r\n     bAlternateSetting  :    0x0\r\n     bNumEndpoints      :    0x1\r\n     bInterfaceClass    :    0x2 CDC Communication\r\n     bInterfaceSubClass :    0x2\r\n     bInterfaceProtocol :   0xff\r\n     iInterface         :    0x8 RNDIS Communications Control\r\n      ENDPOINT 0x82: Interrupt IN ==========================\r\n       bLength          :    0x7 (7 bytes)\r\n       bDescriptorType  :    0x5 Endpoint\r\n       bEndpointAddress :   0x82 IN\r\n       bmAttributes     :    0x3 Interrupt\r\n       wMaxPacketSize   :    0x8 (8 bytes)\r\n       bInterval        :    0x9\r\n    INTERFACE 1: CDC Data ==================================\r\n     bLength            :    0x9 (9 bytes)\r\n     bDescriptorType    :    0x4 Interface\r\n     bInterfaceNumber   :    0x1\r\n     bAlternateSetting  :    0x0\r\n     bNumEndpoints      :    0x2\r\n     bInterfaceClass    :    0xa CDC Data\r\n     bInterfaceSubClass :    0x0\r\n     bInterfaceProtocol :    0x0\r\n     iInterface         :    0x9 RNDIS Ethernet Data\r\n      ENDPOINT 0x81: Bulk IN ===============================\r\n       bLength          :    0x7 (7 bytes)\r\n       bDescriptorType  :    0x5 Endpoint\r\n       bEndpointAddress :   0x81 IN\r\n       bmAttributes     :    0x2 Bulk\r\n       wMaxPacketSize   :  0x200 (512 bytes)\r\n       bInterval        :    0x0\r\n      ENDPOINT 0x1: Bulk OUT ===============================\r\n       bLength          :    0x7 (7 bytes)\r\n       bDescriptorType  :    0x5 Endpoint\r\n       bEndpointAddress :    0x1 OUT\r\n       bmAttributes     :    0x2 Bulk\r\n       wMaxPacketSize   :  0x200 (512 bytes)\r\n       bInterval        :    0x0\r\n    INTERFACE 2: CDC Communication =========================\r\n     bLength            :    0x9 (9 bytes)\r\n     bDescriptorType    :    0x4 Interface\r\n     bInterfaceNumber   :    0x2\r\n     bAlternateSetting  :    0x0\r\n     bNumEndpoints      :    0x1\r\n     bInterfaceClass    :    0x2 CDC Communication\r\n     bInterfaceSubClass :    0x2\r\n     bInterfaceProtocol :    0x1\r\n     iInterface         :    0xc CDC Abstract Control Model (ACM)\r\n      ENDPOINT 0x84: Interrupt IN ==========================\r\n       bLength          :    0x7 (7 bytes)\r\n       bDescriptorType  :    0x5 Endpoint\r\n       bEndpointAddress :   0x84 IN\r\n       bmAttributes     :    0x3 Interrupt\r\n       wMaxPacketSize   :    0xa (10 bytes)\r\n       bInterval        :    0x9\r\n    INTERFACE 3: CDC Data ==================================\r\n     bLength            :    0x9 (9 bytes)\r\n     bDescriptorType    :    0x4 Interface\r\n     bInterfaceNumber   :    0x3\r\n     bAlternateSetting  :    0x0\r\n     bNumEndpoints      :    0x2\r\n     bInterfaceClass    :    0xa CDC Data\r\n     bInterfaceSubClass :    0x0\r\n     bInterfaceProtocol :    0x0\r\n     iInterface         :    0xd CDC ACM Data\r\n      ENDPOINT 0x83: Bulk IN ===============================\r\n       bLength          :    0x7 (7 bytes)\r\n       bDescriptorType  :    0x5 Endpoint\r\n       bEndpointAddress :   0x83 IN\r\n       bmAttributes     :    0x2 Bulk\r\n       wMaxPacketSize   :  0x200 (512 bytes)\r\n       bInterval        :    0x0\r\n      ENDPOINT 0x2: Bulk OUT ===============================\r\n       bLength          :    0x7 (7 bytes)\r\n       bDescriptorType  :    0x5 Endpoint\r\n       bEndpointAddress :    0x2 OUT\r\n       bmAttributes     :    0x2 Bulk\r\n       wMaxPacketSize   :  0x200 (512 bytes)\r\n       bInterval        :    0x0\r\n    INTERFACE 4: Mass Storage ==============================\r\n     bLength            :    0x9 (9 bytes)\r\n     bDescriptorType    :    0x4 Interface\r\n     bInterfaceNumber   :    0x4\r\n     bAlternateSetting  :    0x0\r\n     bNumEndpoints      :    0x2\r\n     bInterfaceClass    :    0x8 Mass Storage\r\n     bInterfaceSubClass :    0x6\r\n     bInterfaceProtocol :   0x50\r\n     iInterface         :    0x1 Mass Storage\r\n      ENDPOINT 0x85: Bulk IN ===============================\r\n       bLength          :    0x7 (7 bytes)\r\n       bDescriptorType  :    0x5 Endpoint\r\n       bEndpointAddress :   0x85 IN\r\n       bmAttributes     :    0x2 Bulk\r\n       wMaxPacketSize   :  0x200 (512 bytes)\r\n       bInterval        :    0x0\r\n      ENDPOINT 0x3: Bulk OUT ===============================\r\n       bLength          :    0x7 (7 bytes)\r\n       bDescriptorType  :    0x5 Endpoint\r\n       bEndpointAddress :    0x3 OUT\r\n       bmAttributes     :    0x2 Bulk\r\n       wMaxPacketSize   :  0x200 (512 bytes)\r\n       bInterval        :    0x1\r\n\r\nI have removed the default drivers which get loaded by the device by using the sudo rmmod command. The drivers removed by me are: cdc_acm, rndis_wlan, rndis_host. I am using the device as USB Mass Storage for Bulk Transfer (Interface 4)\r\nI am running the following python code:\r\n``` import sys, usb.core, time\r\n#For USB OTG Hexadecimal VendorID=0x1d6b & ProductID=0x104\r\ndev = usb.core.find(idVendor=0x1d6b, idProduct=0x104) \r\ninterface=4\r\nif dev is None:\r\n    sys.exit(\"No Panic button found in the system\");\r\n\r\ntry:\r\n    if dev.is_kernel_driver_active(4) is True:\r\n        dev.detach_kernel_driver(4)\r\nexcept usb.core.USBError as e:\r\n    sys.exit(\"Kernel driver won't give up control over device: %s\" % str(e))\r\n\r\ntry:\r\n    dev.set_configuration()\r\n    dev.reset()\r\nexcept usb.core.USBError as e:\r\n    sys.exit(\"Cannot set configuration the device: %s\" % str(e))\r\nprint dev\r\nendpoint_in = dev[0][(interface,0)][0]\r\nendpoint_out = dev[0][(interface,0)][1]\r\nprint endpoint_in\r\nprint endpoint_out\r\nmsg = 'test123'\r\ndata1 = dev.write(endpoint_out, msg,100)\r\nprint data1\r\ndata = dev.read(endpoint_in, len(msg),100)\r\nsret = ''.join([chr(x) for x in data])\r\nprint sret\r\nprint repr(data.tostring())\r\nusb.util.dispose_resources(dev)\r\n```\r\nI am able to write to the device using \"data1 = dev.write(endpoint_out, msg,100)\" but when I try reading from the device \"data = dev.read(endpoint_in, len(msg),100)\", I am getting the following error:\r\n\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/usr/local/lib/python2.7/dist-packages/usb/core.py\", line 988, in read\r\n    self.__get_timeout(timeout))\r\n  File \"/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py\", line 833, in bulk_read\r\n    timeout)\r\n  File \"/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py\", line 936, in __read\r\n    _check(retval)\r\n  File \"/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py\", line 595, in _check\r\n    raise USBError(_strerror(ret), ret, _libusb_errno[ret])\r\nusb.core.USBError: [Errno 32] Pipe error\r\n\r\nI tried to search for this issue but could not find much.\r\nIn [http://christopherpeplin.com/2012/02/bulk-usb-throughput](url), the following is mentioned:\r\n\r\n> The complete fix for OpenXC’s use case will be to make sure every message is padded out to 64 bytes and to request bulk transfer sizes that are big enough to get good throughput but small enough to not be too delayed. I have yet to confirm, but my understanding is that if we request a 4KB read and don’t mark the end of the transfer with a less-than-max length packet, the host device will block waiting for the rest of the requested data.\r\n\r\nI tried to send a 64 byte data using the following string:\r\nabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\r\nThe write command shows 64 bytes written but the same error 32 arises when I try to read from the device. I am new to USB programming and I am stuck up here. Can somebody please help?"},"comment":{"url":"https://api.github.com/repos/pyusb/pyusb/issues/comments/410900148","html_url":"https://github.com/pyusb/pyusb/issues/207#issuecomment-410900148","issue_url":"https://api.github.com/repos/pyusb/pyusb/issues/207","id":410900148,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMDkwMDE0OA==","user":{"login":"mcuee","id":1294740,"node_id":"MDQ6VXNlcjEyOTQ3NDA=","avatar_url":"https://avatars3.githubusercontent.com/u/1294740?v=4","gravatar_id":"","url":"https://api.github.com/users/mcuee","html_url":"https://github.com/mcuee","followers_url":"https://api.github.com/users/mcuee/followers","following_url":"https://api.github.com/users/mcuee/following{/other_user}","gists_url":"https://api.github.com/users/mcuee/gists{/gist_id}","starred_url":"https://api.github.com/users/mcuee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcuee/subscriptions","organizations_url":"https://api.github.com/users/mcuee/orgs","repos_url":"https://api.github.com/users/mcuee/repos","events_url":"https://api.github.com/users/mcuee/events{/privacy}","received_events_url":"https://api.github.com/users/mcuee/received_events","type":"User","site_admin":false},"created_at":"2018-08-07T01:09:07Z","updated_at":"2018-08-07T01:09:07Z","author_association":"NONE","body":"As long as you know the communication protocol or you have control on your device side (it seems to me that you have control since this is a development board), then you can use the interfaces to communicate with the device, for example, CDC-ACM will be the serial port and you can use pySerial for the communication. rndis will come out as the network interface and you can use those network related python (or other language) packages for the communication. "}}
{"actor":{"display_login":"mcuee"}}