Rusty, abandoned bytes.
abandoned bytes



Multiple mice have been found in our attic before, so I know the noise. The usual solution is a standard mousetrap, which kills our “guests” – not very friendly hospitality…

How about something new?

Here is an automatic mousetrap I built yesterday. The main component is the actuator: A solenoid found in one of Vienna University of Technology’s trash containers. It is triggered by an infrared light barrier.

I caught the first mouse after just 2 hours!

SpamAssassin getting old

I love SpamAssassin - it saves me from having to delete around 100 spam e-mails per day which appear in my inbox (it’s been almost a decade that my old e-mail address is active, and it probably appears in all major e-mail address packages that spammers buy). However, as it’s the third time I need to empty and re-start the Bayes database from scratch, it seems that the autolearn feature has yet to learn to forget.

It appears that after some while (around 6 months), the autolearn starts to bias the Bayes database towards treating spam as ham, up until the point that wristwatches and elaborate male organ enhancers with widespread names start to have BAYES_50 score.

The only help seems to be clearing the database:

sa-learn --clear

Obviously, the Bayesian filter needs to be re-trained afterwards, which can either happen automatically based on the other filter mechanisms in SpamAssassin (may take a while), or manually (which is a PITA).

I guess that there is some need to forget continuously, so that new training stuff can replace old, errorneous (self) training records.

I’d appreciate any comments on this issue.

Yaca: CAN signal problems

bad signal on CANL

Blue: CANH, yellow: CANL - this should be a differential signal.

I can’t connect nodes in the workshop. The problem is old, but I always thought it had to do with the connector there, but now that I’ve checked - no wonder, I would be suprised to see it work like this. On the right side is an oscilloscope picture of the CAN bus lines.

I have figured out by now that this difference in the appearance of the two signals has at least partially something to do with the ground difference. As all nodes are supplied centrally, the ground difference builds up along the wire, and gets up to around 1.2 V difference at the furthermost node.

I’ve read a bit about CAN ground, and it seems like many experienced people are suggesting that there is not only no need for exactly the same ground potential, but that there is no need for a ground line at all. I, however, can’t really imagine what the MCP2551 is going to do to pull a bus line, which is already below its ground potential, further down.

Hence, I’m trying to make use of currently unused wires: From the workshop to the laundry, the cable is a main bus line without a CAN pair going back, and there is no 5 V supply, thus there are 4 additional wires which can be used to strengthen the ground potential in the laundry. The cable to the computers doesn’t have a CAN pair back either (and only the 5 V ground is used), so there are 3 additional wires to transport ground potential.

Altough the signal has now improved a bit (and doesn’t jump around on the oscilloscope screen as much), there are still error frames (sadly I didn’t capture the oscilloscope screen for these yet) now and then, and the communication to the workshop still doesn’t work, altough the rest still does talk.

I will have to read up more on how to track down errors. The cable to the pool could also be worthwile for being “modded” with additional ground lines (5 V pair unused to there). Oh, and I’m sure the TV distribution (or the nodes there) would be happy about some huge elcap too.

I can’t mention how glad I am that this is not all happening at a time where much more things are automated - it’s currently a rather convenient field test as I’m able to shut down the whole bus for measurements without having to sit in the dark, being locked out etc.

Edit 2012-11-25: The problem turned out to be in the distribution box in the laundry, which connects different parts of the bus together. There was a loose contact in one of the connectors, which split one of the differential CAN signal lines into two parts. Interestingly, CAN is rugged enough to work most of the time with only one of the two signal lines.

Brave New World

People still went on talking about truth and beauty as though they were the sovereign goods. Right up to the time of the Nine Years’ War. That made them change their tune all right. What’s the point of truth or beauty or knowledge when the anthrax bombs are popping all around you? That was when science first began to be controlled - after the Nine Years’ War. People were ready to have even their appetites controlled then. Anything for a quiet life. We’ve gone on controlling ever since. It hasn’t been very good for truth, of course. But it’s been very good for happiness.

— Aldous Huxley - Brave New World

Image downscaling

Lately, my father needed some image scaling code for an application (yep, he is a software engineer). You would suppose that there are many libraries for scaling images, as there are a whole bunch of algorithms like bilinear, bicubic etc. Lots of googling, however, leads to another impression: There are quite a few libraries, but with enormous dependencies themselves, one even requiring the whole GTK+ library!

The project my father is working on is being written in Borland C++ Builder (yuck!). The Borland C++ toolkit itself doesn’t support anything other than scaling with the nearest neighbor algorithm, which looks very ugly (pixely). Tired of googling, I wrote a small image scaling code which doesn’t depend on anything else (than a standard C++ compiler). I’ve made my own considerations on how to scale down an image, but the nearest thing to it is the bilinear interpolation algorithm (I really don’t like the mathematical approach on Wikipedia by the way. I’m a more a programmer than a mathematician!)

The downscaling is done, self-explainingly, by the scale() function. The code is an optimized version including macros, which unfortunately is not very readable. I suggest you just use it ;-) You could also bug me to make a nicer version.

readpng() and the PNG library are only needed to provide some sample image input, which you should replace by some other form of getting pixels. Update: A version with BMP input is now available in the ZIP archive.

At the moment, the code only supports downscaling. It seems that a few % upscaling is no problem though.

Update: Seems like you need the following stuff starting from libpng 1.4:

#define png_infopp_NULL (png_infopp)NULL
#define png_voidp_NULL (png_voidp)NULL

Update 2: Some compressed PNGs were not extracted with the proper pixel data - this bug is now fixed.


Scripted SFTP password login

The default sftp program Linux (at least Ubuntu) uses is written with security in mind, instead of the user’s wishes. Stating that “writing your password into a script is insecure” (which it obviously is, I fully agree!), they restrict the password input to the terminal, and somehow the smart-ass programmers managed to find the terminal even when all standard I/O (stdin, stdout, stderr) are passed through pipes.

Obviously, this is a pain in the ass if you want to upload stuff to Sourceforge automatically, as the only solution for automated logins is to use ssh key files. Uploading ssh keys to Sourceforge, however, is not possible, thus, I strived for another program providing better functionality.

Being an ex-Windows-user, PuTTY promptly came to mind. psftp provides nice functionality: it is able to read the password as a parameter and even hides it in the process list output (I guess it must have forked to achieve that). Now, the familiar unix style known from automating ftp sessions can be used to script it:

psftp -pw password <<EOF
cd /some/folder
put some.file

Dismantling Ford radio 4000 RDS

Question: What can you do if, in an accident, someone smashed the volume “button” of a Ford radio, and the volume doesn’t work anymore?

Ford Radio key Ford Radio - repaired front pcb


  • Release the radio (without a professional tool for that, the two metal things in the picture were made out of a flower holding facility, the diameter is 2 mm or 2.5 mm with the white lacquer, that still fits)
  • Remove the front panel with a Torx-8 screwdriver
  • Look concerned because the PCB is completely wracked where the rotary encoder was
  • Take a fitting piece of prototype PCB, drill and solder in the rotary encoder
  • Swear because there is no room to put the prototype PCB behind the PCB of the front panel (the rotary encoder and so the prototype PCB will receive all the force from pressing it, so it needs to be mounted solidly)
  • Dismantle the PCB with a Torx-6 screwdriver, put the prototype PCB behind it, mount it again
  • Wire up everything and have fun with a working volume control