ChillPanel – Linux

Asetek Under Linux?

Last update 19th April 2008

Well it looks like I’ve sorted the intermittent connection problem, and it was to do with sending too many characters in my packet. I’ve now completed version 0.1 of my waterchilld for linux.

At this point it has many issues, not least that it’s only been tested on my my linux box with my Waterchill pump. Currently, there is no way to view the current temperatures or the fan speeds. This is rather a big issue, but I’m at a loss as to how to make that data available. I’ve considered writing a file or share memory but I’ve not got very far with either.

Anyhow, enough of what it can’t do, and on to what it can do.

In summary to get it working for you, you’ll need to compile the program, create a configuration file for it then run it.


I’ve been compiling the program with the command :

gcc waterchilld.c -o waterchilld -L/usr/local/lib/hid -lhid -lm

Now I actually paste this in this page, I realise I ditched the hid library, so in all likelihood it’ll compile with just:

gcc waterchilld.c -o waterchilld -lm

… but I’ll check and update this page.

Create the config file

You’ll need to create the file /etc/waterchill.conf and have it look like this :

# waterchilld configuration file


These are the default values for the program, just as it is in ChillPanel. maxtemp1 is the temperature that fan1 will run at 100% speed at. maxtemp2 is the temperature that fan1 will turn off at. The program will scale the fan speed between 0% and 100% when the temperature is between your set max and min values. The exact same is true of the xxxtemp2 values.

Run the program

This is a daemon program, so it’s designed to be run as root and forgot about, it’ll just carry on varying your fan speeds based on your temperatures and the values you’ve set in the config file. While it’s running as a daemon, you can see what’s happening with cat /var/log/waterchilld.log any errors and reports will be stored in there. As it is written now, it writes crazy amounts of information to that file, so keep your eye on how big it is getting.

If you want to run it as a interactive (ish) command line program, have a hunt in the source for the line that reads :

const int daemon_mode = 1;

and change the 1 to a 0. Now the program will not appear to close right away, and will give you information about its current state to your terminal. The big difference here is that once you press CTRL-C to exit the program, it won’t keep running in the background. This daemon mode function will become a command line argument I expect once I work out they best way of doing them.

In daemon mode the program responds to two signals. SIGHUP will instruct the program to re-read the config file. So lets say you want to change the maxtemp1 to 40 while the programs running, but without restarting it, just change the config file to reflect the change you want, then issue a SIGHUP signal. To issue that signal from the prompt, you’ll fist need the programs PID, you can find this with the command ps -A | grep waterchilld. Once you have the PID, just issue the command kill -1 <PID>, replacing <PID> with the PID you found with the ps command (eg. kill -1 7451). This is probably useful for scripts, so if you don’t understand it, then you probably don’t need to.

To stop the daemon running just issue a killall waterchilld as root.

I expect to write some init scripts to simplify all this.

Oops, I almost forgot, here’s the source code try not to laugh at my code. I’d advise a right click save as, rather than clicking the file directly. It’s not pretty if you click it directly under windows 🙂

Update 18th April 2008

After another go at introducing the Asetek pump to Linux I’ve met with some success, the key being throwing the HID specs out the window (just like I’m realising Asetek did) I’m talking to the device with USB calls only instead of trying to mess about with descriptor records etc.

I’ve made enough progress to make me now think that a temperature control daemon is possible and probably only a weekend away. I’ve not written in C for years and i’m finding it tough going, I can’t remember the simplest of things and find myself googling them all the damn time. Worse still is that I flip back to Chillpanel in Delphi (pascal) to pull some info and I’m getting C and Pascal confused now. Never mind, next time I write a php program it’ll all be gone from my head anyway.

I’ve now got working C code that can read the raw values from the Asetek semi-reliably. I’ve got a problem when after a few reads the Asetek won’t play any more and won’t listen to any more commands until it’s been powered off and on, something I’m hoping to iron out eventually as its not convinient taking the side off your PC every 10 minutes to reset your pump 🙂 I’m thinking it’s a mismatch in the number of byte’s I’m trying to put in the control packets, but more investigation is called for. Most of the time given 30 seconds or so, the Asetek comes back to life and carrys on, so for now I’m going to concentrate on turning the simple bits that the Asetek pump spits out into meaningful temperature information. Fortunately I’ve already done the mind crushing calculus required for this job when I did the Chillpanel for windows which for reference I’ve put below in it’s pascal form :

Temp2A[0] := Byte(PChar(Data)[4]);
Temp2A[1] := Byte(PChar(Data)[3]);
Temp2Int := smallint(Temp2A);
Temp2Int := (Temp2Int div 64) and $3FF;
Temp2Flo := 277.752553+ (-105.205508*power(Temp2Int,0.152040025));
if tFah.checked then Temp2Flo := Temp2Flo*(9/5)+32;

To be honest, now I look at it I wonder if all that is neccessary, but it was such a damn hard thing to get it working, once it did work, I never bothered simplifying it. If theres a C loon reading, I’d appreciate that simplified down (prolly to some self calling recursive function you crazy buggers).

Once I’ve got the temps being read, it should be fairly trivial to make a daemon and have a config file in /etc that contains the same config information as chillpanel and automatically control the fans based on temperature. I intend to publish the speeds and temps in some kind of /dev file or something so the whizzkids can write a GUI for it all, I might even attempt one myself.

Older and less positive comment

I spent two full days banging my head against Ubuntu 7.10 trying every trick I could to get to talk to the Asetek, but with absolutely no success. Usually, if I spend that kind of time on something, I can at least make SOME headway; find out why I can’t go further or get an idea what I need to learn and understand to get it working. All I had to show after 2 days work was a program that could tell me if an asetek device was plugged in, and I got that working within 20 minutes of starting. The rest of the time was a lesson in frustration.

I’ve read through the source code of libusb, libhid and even some kernel source trying to find out what the problem is, and after two days, I believe it to be a fundamental problem with the Asetek pump and USB handling in Linux, I’d even go as far as to consider it a bug in the USB code of Linux itself.

After this solid two days of hacking about with C programs in linux, all I know is that even such Linux USB tools such as lsusb and a compiled version of test_libhid.c can’t get a descriptor out of the Asetek, mostly failing with “Broken pipe” messages. Once I realised that software that works perfectly with other USB devices doesn’t work with the pump, I started looking at what Linux thought of the pump. During bootup I would get “device descriptor read/64, error -110” errors every few lines, and after tracing back the device id, it’s the Asetek, so even the kernel can’t get the descriptors out of the thing.

The best page I found about writing user space programs for interaction with HID USB devices was here, but being old, a lot of the (seemingly) useful software for reverse engineering HID USB devices has long disappeared. I spent 2 hours searching for “A Windows application available from Arnaud” mentioned in the article, and totally failed to find it anywhere on the internet.

Finally, in desperation, knowing that the device works perfectly in Windows, I installed Virtual Box and passed through the Asetek pump USB device. The XP VM announced “Unrecognised USB Device” suggesting to me that the VM of XP couldn’t get any info out of the pump, no doubt as the information is just passed through from linux, and linux can’t get any descriptor out of the device either.

Conversely, I reboot, select Vista from the startup menu, and it’s detected right away as a HID device, and chillpanel fires up and controls it without problem. After 2 full days with this big fan on full it was nice when Chillpanel decided enough was enough, and turned the fan off. I let out an actual sigh of relief when that noise stopped, I can tell you.

Given time to dwell on my defeat, I shall try again no doubt. I can’t stand being beaten by plastic and silicon. I plan on unplugging all my USB devices (of which I have many) in the hopes that this will reduce Linuxs’ confusion. Also I’ll try moving the pump to a different USB controller.

Obscure USB device support aside, my overall experience with Ubuntu was pretty good. For web hosting and certain types of servers it’s been hard to beat Linux for a long time, but as a desktop OS it’s never really appealed to me. I had very low expectations after dipping my toe in the Linux pool with Redhat many years ago, and finding a lesson in pain and suffering at the hands of code toting documentation phobic sao-masochists. “why have a button to click with a mouse, when I can type this handy 134 character meaningless command line every time I want to do XYZ” I’m glad geekery has come round to shunning these people from our society and letting common sense prevail.

Ubuntu is pretty cool. I found it surprisingly fast and I really liked that it mostly knew what I wanted to do, and if it didn’t it went and downloaded an app that did without any fuss. It still took the best part of a day to install mind, as it doesn’t support raid arrays “out of the box” so to speak, and as usual the fanboys term the type of raid “fakeraid” so as to belittle your system choice, rather than just fixing the problem. Once you realise you want to stick with your “fakeraid” because you want to dual boot back to Vista when something doesn’t work, you’re into typing in nonsense off a web site at a $ prompt, but it wouldn’t be linux if everything just worked now would it?

For me Ubuntu is a lot closer to an operating system that a non-enthusiast would use, but odd behaviour and a lot of “messing about” to get everything on your system working would put me off. I’m leaving it installed and finding I’m spending more and more time front of it, the feeling I’m constantly fighting it to get what I want done is fading a little now I’ve spent some time customising it. While I don’t see it anywhere near a consumer OS, it is great for enthusiasts who just turn on their PC just to use a PC with no goal, theres then thousands niggles with the thing, and thanks to the openess of the linux platform you can fix each and every one of them yourself if you have the mind and the time.

Still if you want a linux distribution for your desktop, you could do a lot worse than Ubuntu (especially if you’re favourite colour is brown) but it’s still a long way