Re: [pywws] pywws and wh1080 - USB connection fail (timeout)

1,417 views
Skip to first unread message

A Bunting

unread,
Oct 25, 2012, 6:41:25 AM10/25/12
to py...@googlegroups.com
Hi,

On 25/10/12 11:16, Hobride Marcel wrote:
> i have an wh1080, raspberry pi and pywws and it works normally fine.
> but sometimes i have usb connection fail.


This is a common problem with the recent WH1080s and not necessarily
anything related to your configuration.

There is no fix as such, but if you attach the WH1080 console through a
USB hub that supports per-port power control then you can reset the
console's interface programmatically when it hangs.

This means you should only lose a short period of data, if any. It
resumes cleanly each time.

One such USB hub is the Linksys USB2HUB4, which uses an Initio Corp
chipset.

--
A Bunting

Hobride Marcel

unread,
Oct 25, 2012, 7:08:18 AM10/25/12
to py...@googlegroups.com, py...@lineum.org.uk
Hi, thanks for your fast answer.


There is no fix as such, but if you attach the WH1080 console through a
USB hub that supports per-port power control then you can reset the
console's interface programmatically when it hangs.

do you have a link or some lines code for a interface reset?

 

tonino tarsi

unread,
Oct 25, 2012, 8:42:11 AM10/25/12
to py...@googlegroups.com
I also have sometime time-outs and solved it .. retrying . usually alter 2 or maximum 3 times things works fine.

For example this is my code :


while not self._stop.isSet(): if total_runs > 20: log("Tried 20 times to start sensor ... now rebooting") systemRestart() try: sensor = sensor_wh1080.Sensor_WH1080(self.cfg) sensor.GetData() except IndexError, e: print e# or pass, do nothing just ignore that row... pass except IOError,e: log("ERROR with PCE-FWS20 %s . Will retry in 2 seconds..." % e) ret,model,idd,bus = detectWH1080() if ret: usbdevice = "/dev/bus/usb/%s/%s" % (idd , bus ) os.system( "./usbreset %s" % (usbdevice) ) time.sleep(2) total_runs = total_runs + 1 pass except: print "Unexpected error:", sys.exc_info()[0] raise



sensor.GetData() is only a call to pyww.livedata

Tony

 






Il giorno giovedì 25 ottobre 2012 12:16:34 UTC+2, Hobride Marcel ha scritto:
Hello,


i have an wh1080, raspberry pi and pywws and it works normally fine.
but sometimes i have usb connection fail.

 root@raspberrypi ~/weather/pywws-12.10_r547> python TestWeatherStation.py
Traceback (most recent call last):
  File "TestWeatherStation.py", line 145, in <module>
    sys.exit(main())
  File "TestWeatherStation.py", line 91, in main
    raw_fixed = ws.get_raw_fixed_block()
  File "/root/weather/pywws-12.10_r547/pywws/WeatherStation.py", line 578, in get_raw_fixed_block
    self._fixed_block = self._read_fixed_block()
  File "/root/weather/pywws-12.10_r547/pywws/WeatherStation.py", line 610, in _read_fixed_block
    result += self._read_block(mempos)
  File "/root/weather/pywws-12.10_r547/pywws/WeatherStation.py", line 598, in _read_block
    new_block = self.cusb.read_block(ptr)
  File "/root/weather/pywws-12.10_r547/pywws/WeatherStation.py", line 309, in read_block
    return self.dev.read_data(32)
  File "/root/weather/pywws-12.10_r547/pywws/device_pyusb.py", line 132, in read_data
    result = self.devh.interruptRead(0x81, size, 1200)
usb.USBError: Connection timed out

lsusb output:

root@raspberrypi ~/weather/pywws-12.10_r547> lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 1941:8021 Dream Link WH1080 Weather Station / USB Missile Launcher

the only way to solve this problem is a reset of the wh1080. if i do that i lose all date in the wh1080.

is it possible to fix this???

notwithstanding, it a great program

 
 

Brian D

unread,
Oct 25, 2012, 12:00:29 PM10/25/12
to py...@googlegroups.com
You wrote:

> Hi,
>
> On 25/10/12 11:16, Hobride Marcel wrote:
> > i have an wh1080, raspberry pi and pywws and it works normally fine. but
> > sometimes i have usb connection fail.

I have had this problem but not with Raspberry pi. I've had to remove the
batteries and lost all settings in the process.

>
>
> This is a common problem with the recent WH1080s and not necessarily
> anything related to your configuration.

Mine is just afew months old.

>
> There is no fix as such, but if you attach the WH1080 console through a
> USB hub that supports per-port power control then you can reset the
> console's interface programmatically when it hangs.

Is this by powering the weather station via USB and not using the batteries?
If so is all data and settings lost?

>
> This means you should only lose a short period of data, if any. It
> resumes cleanly each time.
>
> One such USB hub is the Linksys USB2HUB4, which uses an Initio Corp
> chipset.
>
I will look into getting one of those.

--
Brian D

Matteo F

unread,
Jul 15, 2013, 11:58:29 AM7/15/13
to py...@googlegroups.com
For all with usb connection timeout, try this (it make a fake-phisical usb restart).

1) Make a new file usbreset.c with this content:

/* usbreset -- send a USB port reset to a USB device */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>

int main(int argc, char **argv)
{
const char *filename;
int fd;
int rc;
if (argc != 2) {
fprintf(stderr, "Usage: usbreset device-filename\n");
return 1;
}
filename = argv[1];
fd = open(filename, O_WRONLY);
if (fd < 0) {
perror("Error opening output file");
return 1;
}
printf("Resetting USB device %s\n", filename);
rc = ioctl(fd, USBDEVFS_RESET, 0);
if (rc < 0) {
perror("Error in ioctl");
return 1;
}
printf("Reset successful\n");
close(fd);
return 0;
}


2) Compile it with CC 
cc usbreset.c -o usbreset

3) Make it executable
chmod +x usbreset


4) Get bus/device of weather station:
lsusb


5) For me, the weather station is this (ignore missile launcher :) ):

[root@localhost zurli]# lsusb
Bus 001 Device 002: ID 1941:8021 Dream Link USB Missile Launcher
 

6) reset with this (change values of bus AND device):
sudo ./usbreset /dev/bus/usb/001/002

7) Output like this, device is now rebooted

[root@localhost zurli]# sudo ./usbreset /dev/bus/usb/001/002
Resetting USB device /dev/bus/usb/001/002
Reset successful



Il giorno sabato 2 febbraio 2013 10:48:00 UTC+1, gaetan...@gmail.com ha scritto:
Hello Tony,
 
Where did you insert this code ? In the weatherstation.py ?
Could you send me the modified program where you inserted this snippet of code ?
I' ve got the samel problem and wish the problem to be solved, or to find the best workaround.
 
Thanks a lot in advance.
 
Gaëtan
Reply all
Reply to author
Forward
0 new messages