WH1080 weather station support in RDOS

This forums is for OS project announcements including project openings, new releases, update notices, test requests, and job openings (both paying and volunteer).
Post Reply
rdos
Member
Member
Posts: 3286
Joined: Wed Oct 01, 2008 1:55 pm

WH1080 weather station support in RDOS

Post by rdos »

OK, so I now I can readout the weather data from the weather station I purchased in december. It is a HID USB-device, with no protocol documentation available. I found some information in the wview project, but it turns out that some critical pieces of that code doesn't work properly (at least not on top of my HID interface).

I now also have a HID-API for applications that is useful for other propietary implementations of HID class.
rdos
Member
Member
Posts: 3286
Joined: Wed Oct 01, 2008 1:55 pm

Re: WH1080 weather station support in RDOS

Post by rdos »

The driver needed some modifications. Apparently, after it run a few hours against the weather station, something locked-up. Not only that, but it seemed like it was not my driver, but the weather station itself as it needed a cold reboot in order to work again. I could reproduce this on a different computer with a different USB chip as well.

OK, so it is "don't bother with the documentation" (non-existant) and "don't bother about the reverse-engineered C code" (it's not garanteed to be stable), but dig out an USB logger and make sure you send exactly the same data as the Windows based program that is delivered with the weather station.

So, once I did this, I found out they seem to read a couple of uneccesary locations, and that they do things in a slightly different way compared to the C code for Linux. Since they should have tested their own implementation's stability I suppose mimicking it in every detail should result in a stable driver.

Anyway, I found a bug in my HID driver, and then I modified my code to mimick the Windows program, and it has run for a little more than an hour now. I suppose I will know if it is stable by tomorrow.
User avatar
xenos
Member
Member
Posts: 1118
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: WH1080 weather station support in RDOS

Post by xenos »

Very nice! Would you mind sharing your findings, such as the communication protocol used between your weather station and driver, or maybe provide a link to your source code? This is exactly the kind of information I'm trying to gather in my database - feel free to create a wiki page if you like :)
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
rdos
Member
Member
Posts: 3286
Joined: Wed Oct 01, 2008 1:55 pm

Re: WH1080 weather station support in RDOS

Post by rdos »

The main class is here: http://rdos.net/vc/viewvc.cgi/trunk/cla ... iew=markup
The HID class is also needed: http://rdos.net/vc/viewvc.cgi/trunk/cla ... iew=markup

The HID device driver is here: http://rdos.net/vc/viewvc.cgi/trunk/ker ... iew=markup

A problem with USB-devices though is that they are all related to the underlying USB stack, so none of the above source could be used directly to write a new driver for a new OS. The ReadHid / WriteHid interface seems to be available in Linux too so that makes it slightly easier. In fact, I made the interface that way because that was what wview used.

Although I'm not 100% sure it is stable yet. I had one stop yesterday, but since then it seems to have run without problems. OTOH, the stop yesterday was in the USB-interface in RDOS, and it didn't hangup the weather-station.

I'd look into posting it on your wiki once it is stable enough.
User avatar
xenos
Member
Member
Posts: 1118
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: WH1080 weather station support in RDOS

Post by xenos »

Indeed it's a bit hard to understand the code without knowing the underlying USB implementation... But anyway, at least it gives some broad idea of where to find which data, and which command bytes are needed to trigger some action.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
rdos
Member
Member
Posts: 3286
Joined: Wed Oct 01, 2008 1:55 pm

Re: WH1080 weather station support in RDOS

Post by rdos »

I've had regular hang-ups in the USB communication for quite some time, but I think this is no longer an issue after a few fixes in the driver. The current driver looks quite different from the wview driver, and I have strong suspicions that the wview driver is not working properly.

For one thing, sometimes the weather station doesn't answer a request message, and then the driver will make a new attempt. However, as this is made, the weather station sometimes seems to answer with the lost package. In order to fix this, I check some of the packages that I know have a certain content, and if they are wrong, I read and discard 8 bytes at a time (this is the size of a returned package) until I get the expected package. After these modifications were made a few days ago, I've had no more failures.
Post Reply