USB errors on PiZero and RPi 3

803 views
Skip to first unread message

Jon Bartlett

unread,
Mar 5, 2018, 12:41:42 PM3/5/18
to pywws
I've pulled my contributions on this topic into a separate thread from the original 'IOError: station is not logging data' - so as to allow Robert to continue his investigations - mine are going in a different direction :

Just to recap : I have several WH1080 clones : Maplin N96GY x2 and a Forever Speed WH1080  - in fact its a WH1080PC, as it has a wireless clock. These devices range from 2012 to 2018 - and all have different firmware numbers on startup.
They have been giving me problems of USB reading - and I am using Raspberry Pi(s) to read them.  At least one appears to be 'broken' in that the Abs pressure is always zero - and even when I get it to read without pywws crashing, some of the readings are incorrect.  As a side note, my old N96GY circa 2012 gives an audible 'relay click' when attaching the USB cable - the newer devices do not (making me think they're not so power hungry from the USB).

Taking the newest weather stations (Forever Speed WH1080PC) :
If I use a Raspberry Pi 2, No Powered USB hub; all seems quite stable from pywws - including LiveLogging for several hours - Hurrah !

If I take the exact same memory SIM card and place in a Raspberry pi Zero W, and adjust the cables (again, no powered USB hub to the weather station) - DataLogging is OK - although occasionally gives a similar USB error in LiveLogging or DataLogging
:
pi@PiZero-W:~ $ sudo python -m pywws.LogData -v /home/pi/weather/data
17:12:37:pywws.Logger:pywws version 17.11.0, build 1380 (b01d94a)
17:12:37:pywws.Logger:Python version 2.7.13 (default, Nov 24 2017, 17:33:09)
[GCC 6.3.0 20170516]
17:12:37:pywws.WeatherStation.CUSBDrive:using pywws.device_libusb1
17:12:39:pywws.DataLogger:Synchronising to weather station
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/pywws-17.11.0-py2.7.egg/pywws/LogData.py", line 309, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/pywws-17.11.0-py2.7.egg/pywws/LogData.py", line 306, in main
    DataStore.data_store(root_dir)).log_data(sync=sync, clear=clear)
  File "/usr/local/lib/python2.7/dist-packages/pywws-17.11.0-py2.7.egg/pywws/LogData.py", line 210, in log_data
    for data, last_ptr, logged in self.ws.live_data(logged_only=(sync > 1)):
  File "/usr/local/lib/python2.7/dist-packages/pywws-17.11.0-py2.7.egg/pywws/WeatherStation.py", line 440, in live_data
    new_ptr = self.current_pos()
  File "/usr/local/lib/python2.7/dist-packages/pywws-17.11.0-py2.7.egg/pywws/WeatherStation.py", line 586, in current_pos
    self._read_fixed_block(0x0020), self.lo_fix_format['current_pos'])
  File "/usr/local/lib/python2.7/dist-packages/pywws-17.11.0-py2.7.egg/pywws/WeatherStation.py", line 642, in _read_fixed_block
    result += self._read_block(mempos)
  File "/usr/local/lib/python2.7/dist-packages/pywws-17.11.0-py2.7.egg/pywws/WeatherStation.py", line 630, in _read_block
    new_block = self.cusb.read_block(ptr)
  File "/usr/local/lib/python2.7/dist-packages/pywws-17.11.0-py2.7.egg/pywws/WeatherStation.py", line 267, in read_block
    return self.dev.read_data(32)
  File "/usr/local/lib/python2.7/dist-packages/pywws-17.11.0-py2.7.egg/pywws/device_libusb1.py", line 100, in read_data
    result = self.dev.bulkRead(0x81, size, timeout=1200)
  File "/usr/lib/python2.7/dist-packages/usb1/__init__.py", line 1456, in bulkRead
    transferred = self._bulkTransfer(endpoint, data, length, timeout)
  File "/usr/lib/python2.7/dist-packages/usb1/__init__.py", line 1417, in _bulkTransfer
    self.__handle, endpoint, data, length, byref(transferred), timeout,
  File "/usr/lib/python2.7/dist-packages/usb1/__init__.py", line 133, in mayRaiseUSBError
    __raiseUSBError(value)
  File "/usr/lib/python2.7/dist-packages/usb1/__init__.py", line 125, in raiseUSBError
    raise __STATUS_TO_EXCEPTION_DICT.get(value, __USBError)(value)
usb1.USBErrorTimeout: LIBUSB_ERROR_TIMEOUT [-7]


However, I note a couple of things: the RPi Zero has 'USB OCT' ports, rather than full-fat USB.  I see in the syslog that as pywws is running the following are recorded :
Mar  5 17:12:37 PiZero-W kernel: [ 2277.664443] Indeed it is in host mode hprt0 = 00041901
Mar  5 17:12:37 PiZero-W kernel: [ 2278.016028] usb 1-1: reset low-speed USB device number 2 using dwc_otg

I am going to test two things :
- Using a powered USB hub with the PiZero (will take me a day or so to find one)
- Soak testing on the Raspberry pi 2B.

...will get back shortly..



Bob Moss

unread,
May 22, 2018, 4:33:02 AM5/22/18
to pywws
Hi Jon,

Did you get this running reliably? I've just setup a new system with a Raspberry Pi B3+ but would like to migrate it over to a Pi Zero W.

Anyone else running Pywws OK on a PiZero?

Thanks.

Jim Easterbrook

unread,
May 22, 2018, 5:02:17 AM5/22/18
to py...@googlegroups.com
On 22/05/18 09:33, Bob Moss wrote:
>
> Anyone else running Pywws OK on a PiZero?

I've ordered one and am expecting it in a day or two. I'm thinking of
writing a blog post about how I set it up to do pywws.
--
Jim Easterbrook <http://www.jim-easterbrook.me.uk/>

Bob Moss

unread,
May 22, 2018, 6:01:59 AM5/22/18
to pywws
Excellent, that great news, I'll look forward to that.

I've got a PiZeroW here I'm also going to have a play with, so if you need anything testing or to check anything give me a shout.

Jim Easterbrook

unread,
May 24, 2018, 3:09:04 PM5/24/18
to py...@googlegroups.com
On 22/05/18 10:02, Jim Easterbrook wrote:
> On 22/05/18 09:33, Bob Moss wrote:
>>
>> Anyone else running Pywws OK on a PiZero?
>
> I've ordered one and am expecting it in a day or two. I'm thinking of
> writing a blog post about how I set it up to do pywws.

Well, I've made a start on the blog post, not yet on setting up pywws.
http://jim-jotting.blogspot.co.uk/2018/05/setting-up-raspberry-pi-zero-w-to-run.html

Jim Easterbrook

unread,
May 25, 2018, 10:05:02 AM5/25/18
to py...@googlegroups.com
On 24/05/18 20:09, Jim Easterbrook wrote:
> On 22/05/18 10:02, Jim Easterbrook wrote:
>> On 22/05/18 09:33, Bob Moss wrote:
>>>
>>> Anyone else running Pywws OK on a PiZero?
>>
>> I've ordered one and am expecting it in a day or two. I'm thinking of
>> writing a blog post about how I set it up to do pywws.
>
> Well, I've made a start on the blog post, not yet on setting up pywws.
> http://jim-jotting.blogspot.co.uk/2018/05/setting-up-raspberry-pi-zero-w-to-run.html

A bit more progress today, including connecting to a weather station.
I'm using 'pywws-testweatherstation -l -v' to test live data logging
without doing a full pywws setup.

I was getting the USB timeout error problem reported at the start of
this thread, so I've increased the read timeout (in
pywws.device_libusb1) to 10 seconds which seems to have stopped it. I
couldn't believe it sometimes takes 10 seconds to respond though, so I'm
using simple time.time() to measure how long the bulkRead() call takes
and report any values over 1 second. I'm getting numbers in excess of 7
seconds, which will be a problem for pywws's synchronisation to the
weather station clocks.

The "usb 1-1: reset low-speed USB device number 4 using dwc_otg" system
log messages correspond to when I start pywws-testweatherstation.
pywws.device_libusb1 does a device reset on start up.

Jim Easterbrook

unread,
May 26, 2018, 4:54:39 AM5/26/18
to py...@googlegroups.com
On 25/05/18 15:05, Jim Easterbrook wrote:
>
> A bit more progress today, including connecting to a weather station.
> I'm using 'pywws-testweatherstation -l -v' to test live data logging
> without doing a full pywws setup.
>
> I was getting the USB timeout error problem reported at the start of
> this thread, so I've increased the read timeout (in
> pywws.device_libusb1) to 10 seconds which seems to have stopped it. I
> couldn't believe it sometimes takes 10 seconds to respond though, so I'm
> using simple time.time() to measure how long the bulkRead() call takes
> and report any values over 1 second. I'm getting numbers in excess of 7
> seconds, which will be a problem for pywws's synchronisation to the
> weather station clocks.

I think I'm getting somewhere now. I noticed that I was only getting the
very slow reads after pywws had paused for around 5 seconds or more. I
had a hunch that the Pi might be using that apparent inactivity to do
something with the USB port, maybe switching it from "host" mode to
"peripheral" mode.

I've added the line "dtoverlay=dwc2,dr_mode=host" to the end of
/boot/config.txt (and rebooted) and it seems to be working OK now. This
does mean that I can't use the USB port in peripheral mode at all
(without reconfiguring), but I have no plans to do that. There's more
about overlays in /boot/overlays/README.

Bob Moss

unread,
May 29, 2018, 4:45:36 AM5/29/18
to pywws
Sounds like you are making great progress there Jim!

Good find about the peripheral mode - I think that will catch a lot of people out.

I await your next instalment!

Jim Easterbrook

unread,
May 29, 2018, 5:39:47 AM5/29/18
to py...@googlegroups.com
On 29/05/18 09:45, Bob Moss wrote:
> Sounds like you are making great progress there Jim!

Thanks. I've finished off my blog post now. pywws is up and running on
my Pi Zero. It's only been going for two days but it appears to be stable.

Bob Moss

unread,
Sep 11, 2018, 6:50:20 AM9/11/18
to pywws
Hi Jim, was just wondering how the Pi Zero was going? I'm looking at moving over to a zero shortly so wanted to check it was all still OK!

Jim Easterbrook

unread,
Sep 11, 2018, 7:00:11 AM9/11/18
to py...@googlegroups.com
On 11/09/2018 11:50, Bob Moss wrote:
> Hi Jim, was just wondering how the Pi Zero was going? I'm looking at
> moving over to a zero shortly so wanted to check it was all still OK!

It's running perfectly. I can't boast an impressive continuous runtime
as I keep restarting it to test software developments. It's as stable on
the Pi Zero as on any other platform. (Now that I've disabled the USB
"peripheral" mode.)

Stefan Runge

unread,
Sep 11, 2018, 3:43:47 PM9/11/18
to pywws
Hi Jim,

that a perfect news.
Nevertheless i have problems with your settings.
I have a Raspberry Pi 3 Model B Rev 1.2

If i set this line in the config.txt:
dtoverlay=dwc2,dr_mode=host

I get only USB errors:
pi@raspberrypi:~ $ sudo pywws-testweatherstation
21:38:27:pywws.logger:pywws version 18.9.0, build 1631 (779ece9)
Traceback (most recent call last):
  File "/usr/local/bin/pywws-testweatherstation", line 11, in <module>
    load_entry_point('pywws==18.9.0', 'console_scripts', 'pywws-testweatherstation')()
  File "/usr/local/lib/python2.7/dist-packages/pywws-18.9.0-py2.7.egg/pywws/testweatherstation.py", line 118, in main
    raw_fixed = ws.get_raw_fixed_block()
  File "/usr/local/lib/python2.7/dist-packages/pywws-18.9.0-py2.7.egg/pywws/weatherstation.py", line 726, in get_raw_fixed_block
    self._fixed_block = self._read_fixed_block()
  File "/usr/local/lib/python2.7/dist-packages/pywws-18.9.0-py2.7.egg/pywws/weatherstation.py", line 770, in _read_fixed_block
    result += self._read_block(mempos)
  File "/usr/local/lib/python2.7/dist-packages/pywws-18.9.0-py2.7.egg/pywws/weatherstation.py", line 758, in _read_block
    new_block = self.cusb.read_block(ptr)
  File "/usr/local/lib/python2.7/dist-packages/pywws-18.9.0-py2.7.egg/pywws/weatherstation.py", line 350, in read_block
    return self.dev.read_data(32)
  File "/usr/local/lib/python2.7/dist-packages/pywws-18.9.0-py2.7.egg/pywws/device_pyusb1.py", line 103, in read_data
    result = self.dev.read(0x81, size, timeout=1200)
  File "/usr/lib/python2.7/dist-packages/usb/core.py", line 988, in read
    self.__get_timeout(timeout))
  File "/usr/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 851, in intr_read
    timeout)
  File "/usr/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 936, in __read
    _check(retval)
  File "/usr/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 595, in _check
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 5] Input/Output Error


Any idea?

Thanks and best regards,
Stefan

Jim Easterbrook

unread,
Sep 11, 2018, 5:16:40 PM9/11/18
to py...@googlegroups.com
On 11/09/2018 20:43, 'Stefan Runge' via pywws wrote:
>
> that a perfect news.
> Nevertheless i have problems with your settings.
> I have a Raspberry Pi 3 Model B Rev 1.2
>
> If i set this line in the config.txt:
> dtoverlay=dwc2,dr_mode=host
>
> I get only USB errors:
> |
> pi@raspberrypi:~ $ sudo pywws-testweatherstation

[snip]

>   File "/usr/lib/python2.7/dist-packages/usb/backend/libusb1.py", line
> 595, in _check
>     raise USBError(_strerror(ret), ret, _libusb_errno[ret])
> usb.core.USBError: [Errno 5] Input/Output Error
>
> |
>
> Any idea?
Sorry, no. USB has always been a mystery to me, particularly on a Pi. I
just try things I've found that might be relevant until it works.

Stefan Runge

unread,
Sep 11, 2018, 7:17:06 PM9/11/18
to pywws
Hi Jim,

again thanks for all your help. Everything works again!

One last question, you use this settings (dtoverlay=dwc2,dr_mode=host) on a raspberry zero?

Thanks,
Stefan


Jim Easterbrook

unread,
Sep 12, 2018, 2:59:04 AM9/12/18
to py...@googlegroups.com
On 12/09/2018 00:17, 'Stefan Runge' via pywws wrote:
>
> again thanks for all your help. Everything works again!
>
> One last question, you use this settings (dtoverlay=dwc2,dr_mode=host)
> on a raspberry zero?

Yes, in /boot/config.txt (and, obviously, reboot after changing this). I
don't know if the same setting would work on a Pi 3. According to
/boot/overlays/README only the Zero uses dwc2, the others use dwc-otg.

Stefan Runge

unread,
Sep 12, 2018, 4:24:04 AM9/12/18
to pywws
Yes this is correct. By default the PI 3 is using dwc-otg.
After i set dwc2 i seemed to work, but after a while my raspberry freezed.

I will test this a little bit more. If i find a solution i will update it here.

Thanks!
Stefan

Chris DeVita

unread,
Oct 25, 2018, 4:35:26 AM10/25/18
to pywws
I have been running pywws on a pi zero for a year or more, when over the past month It has been gettin these USB errors. I upgraded to the latest version pywws and after adding the lines: 
dtoverlay=dwc2
dr_mode=host
To /boot/config.txt  I still had the same issue.  
I ran rpiupdate ( I have a original zero pre wifi  ) and the stability is back! 
Thanks ! 

Mark Fraser

unread,
Nov 28, 2018, 4:10:19 AM11/28/18
to pywws

On Monday, 5 March 2018 17:41:42 UTC, Jon Bartlett wrote:
Just switched from a 3B+ to a 3A+ and I was getting lots of:
Nov 28 09:00:34 Weather kernel: [ 1406.986678] Indeed it is in host mode hprt0 = 00041901
Nov 28 09:00:34 Weather kernel: [ 1407.331281] usb 1-1: reset low-speed USB device number 2 using dwc_otg
Nov 28 09:00:34 Weather kernel: [ 1407.333443] Indeed it is in host mode hprt0 = 00041901
Nov 28 09:01:04 Weather kernel: [ 1437.532236] Indeed it is in host mode hprt0 = 00041901
Nov 28 09:01:04 Weather kernel: [ 1437.881237] usb 1-1: reset low-speed USB device number 2 using dwc_otg
Nov 28 09:01:04 Weather kernel: [ 1437.883811] Indeed it is in host mode hprt0 = 00041901
Nov 28 09:01:08 Weather kernel: [ 1441.836444] Indeed it is in host mode hprt0 = 00041901
Nov 28 09:01:09 Weather kernel: [ 1442.181233] usb 1-1: reset low-speed USB device number 2 using dwc_otg
Nov 28 09:01:09 Weather kernel: [ 1442.184137] Indeed it is in host mode hprt0 = 00041901
Nov 28 09:02:25 Weather kernel: [ 1518.277972] Indeed it is in host mode hprt0 = 00041901
Nov 28 09:02:25 Weather kernel: [ 1518.621139] usb 1-1: reset low-speed USB device number 2 using dwc_otg
Nov 28 09:02:25 Weather kernel: [ 1518.623607] Indeed it is in host mode hprt0 = 00041901

Added your USB fix to /boot/config.txt and it seems OK now.
Reply all
Reply to author
Forward
0 new messages