ChristophGaukel / ev3-python3

Use python3 to program your LEGO EV3. Communicate via Bluetooth, WiFi or USB. Send direct commands.
Other
47 stars 15 forks source link

usb.core.USBError: [Errno 5] Input/Output Error #14

Open CRcharo opened 2 years ago

CRcharo commented 2 years ago

Hi Christoph, I want to ask you, what does this mistake mean? I have a PC with win10. I'm trying to connect via USB. I follow the instructions exactly on the page: https://ev3-dc.readthedocs.io/en/latest/examples_ev3.html#connect-with-the-ev3-device But the link in this paragraph is broken. Web smallcab.com is not available. Follow this instruction and replace Xin-Mo Programmer by EV3 (when I did it, I clicked the Install Now button in the Inf-Wizard and it was successfully installing). Can you help me? errno5

ChristophGaukel commented 2 years ago

Hi, the address of the link is: https://www.smallcab.net/download/programme/xm-07/how-to-install-libusb-driver.pdf I did open it just now and it was available for me. Maybe it was a temporary problem.

I hope it works for you too.

Kind regards, Christoph

CRcharo commented 2 years ago

www.smallcab.net is available now, but my problem persists. Can you help me please? With Bluetooth everything works perfectly.

import ev3_dc as ev3 with ev3.EV3(protocol=ev3.USB) as my_robot: print(my_robot)

Traceback (most recent call last): File "C:\Users\chasa\AppData\Local\Programs\Python\Python310\direct.py", line 4, in print(my_robot) File "C:\Users\chasa\AppData\Roaming\Python\Python310\site-packages\ev3_dc\ev3.py", line 877, in str f'({self.name})' File "C:\Users\chasa\AppData\Roaming\Python\Python310\site-packages\ev3_dc\ev3.py", line 930, in name self._physical_ev3.introspection(self._verbosity) File "C:\Users\chasa\AppData\Roaming\Python\Python310\site-packages\ev3_dc\ev3.py", line 427, in introspection reply = self.send_direct_cmd( File "C:\Users\chasa\AppData\Roaming\Python\Python310\site-packages\ev3_dc\ev3.py", line 560, in send_direct_cmd self._device.write(_EP_OUT, cmd, 100) File "C:\Users\chasa\AppData\Roaming\Python\Python310\site-packages\usb\core.py", line 989, in write return fn( File "C:\Users\chasa\AppData\Roaming\Python\Python310\site-packages\usb\backend\libusb1.py", line 855, in intr_write return self.write(self.lib.libusb_interrupt_transfer, File "C:\Users\chasa\AppData\Roaming\Python\Python310\site-packages\usb\backend\libusb1.py", line 938, in write _check(retval) File "C:\Users\chasa\AppData\Roaming\Python\Python310\site-packages\usb\backend\libusb1.py", line 604, in _check raise USBError(_strerror(ret), ret, _libusb_errno[ret]) usb.core.USBError: [Errno 5] Input/Output Error

ChristophGaukel commented 2 years ago

Hi, your error occurs, when you send the first request to your EV3 brick, which says, the connection has been established successfully. I conclude: you successfully installed libusb.

You use python 3.10 on win10. Please run this python program:

import ev3_dc
print(ev3_dc.__file__)

This tells you the directory, where ev3_dc has been installed. You find a number of files. Please edit file ev3.py . You will find this code snippet around line 560, where the error occurs:

if platform.system() == 'Darwin':
    self._device.write(cmd)
else:
    self._device.write(_EP_OUT, cmd, 100)

'Darwin' is the system name of MacOS. All other platforms are handled by the second version of the write statement (you again find it in code line 686). We need to understand, why you can connect the device but not send data to it.

It's hard for me to analyze this situation because I can't reproduce it. You find constant _EP_OUT = 0x01 in file constants.py and the last argument is the maximum time for waiting (100 ms). cmd is the byte array of a lengthy direct command. I don't expect that the direct command is the problem. On Unix I would expect a permission problem.

I'm not really optimistic, that this information helps you to understand, what happens on your computer, but maybe it helps to have a bit more knowledge about the background.

Kind regards, Christoph

CRcharo commented 2 years ago

Hi Christoph, I really don't know what to do next. I used your ideas. I tried to do a short program direct.py. It's not working. It fails as you can see in the file sol.txt. I'm a beginner in Python. Do you think that you can help me? I know you definitely have a lot of other work.

Kind regards, Roman Chasák


Od: "Christoph Gaukel" @.> Komu: "ChristophGaukel/ev3-python3" @.> Datum: 13.03.2022 19:06 Předmět: Re: [ChristophGaukel/ev3-python3] usb.core.USBError: [Errno 5] Input/Output Error (Issue #14)

Hi, your error occurs, when you send the first request to your EV3 brick, which says, the connection has been established successfully. I conclude: you successfully installed libusb.

You use python 3.10 on win10. Please run this python program:

import ev3 print(ev3.__file__)

This will tell you the place on your computer, where ev3 has been installed. In this directory you find a number of files. When you edit the source code of file ev3.py, you will find this code snippet around line 560, where the error occurs:

if platform.system() == 'Darwin': self._device.write(cmd) else: self._device.write(_EP_OUT, cmd, 100)

'Darwin' is the system name of MacOS. All other platforms are handled by the second version of the write statement (you again find it in code line 686). We need to understand, why you can connect the device but not send data to it.

It's hard for me to analyze this situation because I can't reproduce it. You find constant _EP_OUT = 0x01 in file constants.py and the last argument is the maximum time for waiting (100 ms). cmd is the byte array of a lengthy direct command. I don't expect that the direct command is the problem. On Unix I would expect a permission problem causes the problem.

I'm not really optimistic, that this information helps you to really understand, what happens on your computer, but maybe it helps to have a bit more knowledge about the background.

Kind regards, Christoph

-- Reply to this email directly or view it on GitHub: https://github.com/ChristophGaukel/ev3-python3/issues/14#issuecomment-1066153295 You are receiving this because you authored the thread.

Message ID: @.***>

Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information.

=== RESTART: C:\Users\chasa\AppData\Local\Programs\Python\Python310\direct.py == C:\Users\chasa\AppData\Roaming\Python\Python310\site-packages\ev3_dc__init.py Windows 00165342E22C ['00:16:53:42:E2:2C'] DEVICE ID 0694:0005 on Bus 001 Address 003 ================= bLength : 0x12 (18 bytes) bDescriptorType : 0x1 Device bcdUSB : 0x200 USB 2.0 bDeviceClass : 0x0 Specified at interface bDeviceSubClass : 0x0 bDeviceProtocol : 0x0 bMaxPacketSize0 : 0x40 (64 bytes) idVendor : 0x0694 idProduct : 0x0005 bcdDevice : 0x216 Device 2.16 iManufacturer : 0x1 LEGO Group iProduct : 0x2 charo iSerialNumber : 0x3 00165342e22c bNumConfigurations : 0x1 CONFIGURATION 1: 2 mA ==================================== bLength : 0x9 (9 bytes) bDescriptorType : 0x2 Configuration wTotalLength : 0x29 (41 bytes) bNumInterfaces : 0x1 bConfigurationValue : 0x1 iConfiguration : 0x1 LEGO Group bmAttributes : 0xc0 Self Powered bMaxPower : 0x1 (2 mA) INTERFACE 0: Human Interface Device ==================== bLength : 0x9 (9 bytes) bDescriptorType : 0x4 Interface bInterfaceNumber : 0x0 bAlternateSetting : 0x0 bNumEndpoints : 0x2 bInterfaceClass : 0x3 Human Interface Device bInterfaceSubClass : 0x0 bInterfaceProtocol : 0x0 iInterface : 0x4 Xfer data to and from EV3 brick ENDPOINT 0x81: Interrupt IN ========================== bLength : 0x7 (7 bytes) bDescriptorType : 0x5 Endpoint bEndpointAddress : 0x81 IN bmAttributes : 0x3 Interrupt wMaxPacketSize : 0x400 (1024 bytes) bInterval : 0x4 ENDPOINT 0x1: Interrupt OUT ========================== bLength : 0x7 (7 bytes) bDescriptorType : 0x5 Endpoint bEndpointAddress : 0x1 OUT bmAttributes : 0x3 Interrupt wMaxPacketSize : 0x400 (1024 bytes) bInterval : 0x4 Traceback (most recent call last): File "C:\Users\chasa\AppData\Local\Programs\Python\Python310\direct.py", line 95, in connect_usb(ev3) File "C:\Users\chasa\AppData\Local\Programs\Python\Python310\direct.py", line 40, in connect_usb ev3._device.read(_EP_IN, 1024, 100) File "C:\Users\chasa\AppData\Roaming\Python\Python310\site-packages\usb\core.py", line 1029, in read ret = fn( File "C:\Users\chasa\AppData\Roaming\Python\Python310\site-packages\usb\backend\libusb1.py", line 864, in intr_read return self.read(self.lib.libusb_interrupt_transfer, File "C:\Users\chasa\AppData\Roaming\Python\Python310\site-packages\usb\backend\libusb1.py", line 954, in __read _check(retval) File "C:\Users\chasa\AppData\Roaming\Python\Python310\site-packages\usb\backend\libusb1.py", line 602, in _check raise USBTimeoutError(_strerror(ret), ret, _libusb_errno[ret]) usb.core.USBTimeoutError: [Errno 10060] Operation timed out

ChristophGaukel commented 2 years ago

Hi Roman, I have tried to again establish a USB connection on a new win10 system. I have done these steps (as described here):

This implements a driver and in my case was successful and as I found, quite easy to handle. After this, pyusb was able to read and write data and ev3_dc worked correctly.

Kind regards, Christoph

CRcharo commented 2 years ago

Hi Christoph, thank you very much for your help and your time. Driver installation was successful. Then I couldn't connect with EV3 brick from python or from original Lego software. I had to uninstall the driver. Never mind! I will look for another way to communicate with brick. Thank you for your great support. I learned a lot from you.

Kind regards, Roman Chasák


Od: "Christoph Gaukel" @.> Komu: "ChristophGaukel/ev3-python3" @.> Datum: 16.03.2022 08:59 Předmět: Re: [ChristophGaukel/ev3-python3] usb.core.USBError: [Errno 5] Input/Output Error (Issue #14)

Hi Roman, I have tried to establish a USB connection on a win10 system. I have done these steps (as described in ):

  • download the newest version of libusb-win32
  • unzip it
  • connect your EV3 device by an USB cable.
  • start file run inf-wizard.exe as administrator
  • select the correct USB-device, its Vendor ID is 0x0694, its Product ID is 0x0005. You find two of them in the device list. Don't select the storage one, take the other one.
  • Give it the device name, you prefer
  • install the driver

In my case this was successfull and as I found, quite easy to handle.

Kind regards, Christoph

-- Reply to this email directly or view it on GitHub: https://github.com/ChristophGaukel/ev3-python3/issues/14#issuecomment-1068837030 You are receiving this because you authored the thread.

Message ID: @.***>