matthewwall / weewx-hp3000

weewx driver for fine offset hp3000 temperature/humidity sensors
GNU General Public License v3.0
5 stars 5 forks source link

Old Raspberry Pi and Timeouts #7

Open Akeemous opened 4 years ago

Akeemous commented 4 years ago

Tried with the old Raspberry Pi 2 and it works fine. The only issue was when the htmls (and graphics) were updated (after REC), I got "Operation time out" sending/reading USB. After the timeout, the weewx crashed.

I did extend the timeout period to 2000 in all three: def write(self, buf): def read(self, timeout=2000): def recv(self):

and it is now running rock solid.

When the timeout happened, the USB was unusable until reset.

Small C code to reset USB: `

include

include

include

include <sys/ioctl.h>

include <linux/usbdevice_fs.h>

void main(int argc, char *argv) { const char filename; int fd; filename = argv[1]; fd = open(filename, O_WRONLY); ioctl(fd, USBDEVFS_RESET, 0); close(fd); return; } `

The resetTemp.sh looks like this: #!/bin/sh /root/resetusblsusb -d 0483:5750 | awk ' { print "/dev/bus/usb/" $2 "/" $4 }' | awk -F':' '{ print $1 }'

And did a custom weewx start script: `#!/bin/sh

while true do echo "Staring WeeWx" /home/weewx/bin/weewxd /home/weewx/weewx.conf sleep 2 echo "Resetting USB" /root/resetTemp.sh sleep 2 done `

A.