Digivation Hack Central

Mapping special names to multiple USB serial adapters

by on Apr.17, 2010, under linux, Solar

The watts clever envi has a USB serial adapter which is a Prolific pl2303. When inserted it is assigned /dev/ttyUSB0 by udev, among a few other symlinks. I have now obtained an RS485 serial adapter on ebay for A$13.98 delivered which uses the exact same chip, which makes it indistiguishable from the envi’s port. What I needed was a way to guarantee uniqueness regardless of the enumeration order on boot or random hot plugin. Naturally, this is for the Aurora GCI which will be installed when they become available in May.

Researching udev a bit, I found /lib/udev/rules.d/60-persistent-serial.rules (mine is a debian system). This file shows how the standard symlinks are done. Since each USB port is unique, I should be able to use that uniqueness to map another symlink to the device.

Firstly plug in the device in the chosen USB port and issue
udevadm info --query=all --name=/dev/ttyUSB1

This shows a heap of stuff but mainly we are interested in
P: /devices/pci0000:00/0000:00:1a.0/usb2/2-1/2-1:1.0/ttyUSB1/tty/ttyUSB1

Create a file in /etc/udev/rules.d/70-persistent-serial.rules which contains

#see /lib/udev/rules.d/60-persistent-serial.rules

ACTION!=”add|change”, GOTO=”persistent_serial_end”
SUBSYSTEM!=”tty”, GOTO=”persistent_serial_end”
KERNEL!=”ttyUSB[0-9]*|ttyACM[0-9]*”, GOTO=”persistent_serial_end”

IMPORT=”usb_id –export %p”
#IMPORT=”path_id %p”

ENV{ID_SERIAL}==””, GOTO=”persistent_serial_end”

# usb nearest ethernet connector
ENV{DEVPATH}==”*usb2/2-2/2-2:1.0*”, SYMLINK+=”serial/by-name/envi”
#bottom front connector
ENV{DEVPATH}==”*usb7/7-1/7-1:1.0*”, SYMLINK+=”serial/by-name/rs485″
# usb below nearest ethernet connector
ENV{DEVPATH}==”*usb2/2-1/2-1:1.0*”, SYMLINK+=”serial/by-name/rs485″


Replug and voila you get /dev/serial/by-name/rs485 which will always be the correct device.

Now I just have to run the wire to where the GCI will be installed.

Comments Off :, , , , , , , , , , more...

Funny Characters for gcc/g++ errors and warnings

by on Apr.01, 2010, under linux

I have found that on some linux systems when you compile with gcc and g++ the error messages have funny characters like

test.c: In function â:
test.c:6: warning: unused variable â

This is due to the default locale being set to something other than the default.

in /etc/default/locale you will have a line like




Restart the shell and compile again and the errors are now meaningful.

test.c: In function 'main':
test.c:6: warning: unused variable 'x'

Naturally you could set it in the local shell for the session, but then you would have to do it every time.

Comments Off : more...

Alternative Fridge-Freezer Anomaly Explanation

by on Mar.27, 2010, under Solar

This explanation is probably wrong because you would expect a deadzone in the power/current quantization levels to stay the same. However, what Ive observed is that the anomaly remains even when the base power varies by -50W to at least +2kW. I believe this precludes the previous explanation because this scale invariance should not exist under these circumstances if the dynamic range switching premise holds, which I still believe to be the case.

A better but not intuitive explanation is that the mechanical vibration of each unit alters the behaviour of the other, increasing the total VA (since that’s what the current sensor measures). The 2 units are located next to each other so are mechanically coupled through the floor.

Of course this explanation could be wrong too but I can’t think of another ATM.

Comments Off more...

Migrating Windows User Ids

by on Mar.12, 2010, under Windows

There are times when domains on windows change and thus your user id changes. However, you may have lots of files owned by you that are not in your user dir. Migrating these user ids to you new one, I’ve found, is not too difficult after all.

All you need is a tool from microsoft called subinacl.

Download and install the msi. Install path is

C:\Program Files\Windows Resource Kits\Tools\subinacl.exe

So use this for the command name below.

First find your old userid. Use a file you know you used to own. E.g. the projects directory.

Subinacl /file c:\projects /display

Copy and paste yours for use in the commands below

Now for the commands. Do for all drives if you have multiple disks.
The lines below are for me of course so sub in your cut S-xxx and new user id

Subinacl /subdir c:\ /accountmig=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx=newdomain\username

also the primary group, which can be found up the top of the display dump.

Subinacl /subdir c:\ "/accountmig=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx=newdomain\Domain Users"

all registry keys

Subinacl /subkeyreg HKEY_CURRENT_USER /accountmig=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx=newdomain\username

Subinacl /subkeyreg HKEY_LOCAL_MACHINE /accountmig=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx=newdomain\username

Subinacl /subkeyreg HKEY_CLASSES_ROOT /accountmig=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx=newdomain\username
(none found, so optional)

and the groups
Subinacl /subkeyreg HKEY_CURRENT_USER "/accountmig=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx=newdomain\Domain Users"

Subinacl /subkeyreg HKEY_LOCAL_MACHINE "/accountmig=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx=newdomain\Domain Users"

Subinacl /subkeyreg HKEY_CLASSES_ROOT "/accountmig=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx=newdomain\Domain Users"

After you are happy

Subinacl /subdir c:\ /suppresssid=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx

Subinacl /subkeyreg HKEY_CURRENT_USER /suppresssid=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx

Subinacl /subkeyreg HKEY_LOCAL_MACHINE /suppresssid=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx

When you are finished, everything you used to own you will own again.

Comments Off more...

Fridge/Freezer Anomaly Explained (Probably)

by on Mar.10, 2010, under Solar

I had some more thoughts on the fridge/freezer anomaly previously detailed.

I had read about the 144 Bug. I suspect it is related to this.

This has to do with the way that the transmitter samples the current sensor. I have noticed that the resolution is much better at lower power than higher power. I suspect this is because the ADC reference in the PIC is connected to a PWM output (smoothed of course) to provide a variable dynamic range sampling system. As you would expect, there would be quite a few range change points in the sampling algorithm. The 144 bug details one at 3kW. I suspect there is also one at somewhere between 450W and 600W which is not calibrated correctly. There are probably others too.

If these range change points are known, it would be easy enough to add fudge factors during datalogging to correct for this. Alternatively I could disassemble the transmitter PIC code and just fix it.

No time for this now.

Another possibility is that the sampling system is non-linear, increasing apparent measurements. Not enough calibrated sample points to prove. Anyhow the former is more likely.

Comments Off :, , , , more...

Watts Clever Fridge + Freezer Power Anomaly

by on Mar.07, 2010, under Solar

I have noticed what appears to be an anomaly in the power presented by my fridge and freezer as measured by the watts clever mains power monitor.

Fridge + Freezer Power Usage

Fridge + Freezer Power Usage

As can be seen, the base load is about 320W which consists of 2 PCs and incidental standbys. The fridge cycles more frequently than the freezer. The fridge power alone is about 75W and the freezer alone is about 100W. You would thus expect their combined power to be 175W. However, this is not so! Measured combined power is about 250W.

Given that the mains power monitor is power factor insensitive, and the compressors of both devices have inductive power factor, this result is unexpected. I’m also assuming that the power factor of the baseload is 1.0, which I think is reasonable as using another power meter showed a power factor of 1 for the PCs and these predominate the baseload.

I would expect the vector sum of fridge+freeze+baseload to be less than the sum of their magnitudes.

Comments Off :, , , , more...

WordPress Install Direct Filesystem Hack

by on Mar.05, 2010, under Wordpress

I use

chgrp -R www-data wp-content
chmod -R g+w wp-content

To make this work with wordpress, edit wp-admin/includes/file.php in function get_filesystem_method() and comment out

if ( getmyuid() == fileowner($temp_file) )


#if ( getmyuid() == fileowner($temp_file) )

If the test file can be written, who cares if it is not owned by the webserver.

You will have to reapply this edit every time wordpress core is updated.

Ref: why-wordpress-asks-connection-info

Comments Off more...

PV Panel Orientation Effectiveness

by on Mar.05, 2010, under Solar

This site has a nice image showing PV panel orientation and the expected output as a percentage of optimal orientation at latitude 35°S.
Variation of solar module output with orientation and tilt angle for latitude 35°S
A fully west or east facing panel will still achieve over 80% of the output of an optimally north facing system. This indicates orientation, whilst critical is not a reason to not install them if no available north facing roof space is available.

Comments Off : more...

Graphing Power Usage

by on Feb.24, 2010, under Solar

Now that I had a mains power meter, I wanted to provide visibility of the house’s power utilization. So yhe next step was to collect power usage data from the Watts clever STC4004/currentcost envi.

I had a play with the linux web software that others had done before me.

I implemented a MQTT server and used a modified perl script to write to it first, as others had done in the UK, but these people were mostly IBM employees and thought it was a good idea to have a middle man feeding data to multiple consumers. It occurred to me that this may be a bit of an overkill. All the consumers also used rrdtool in some way to present the data.

Then I decided to get Danny Tsang’s energy@home project and after a few mods, got it going here.

Please don’t sit on it or I’ll have to password protect the page.

The benefits as I see them are:

    Nicer looking graph
    data is sent raw and the graphing is done locally
    possibility to feed new samples without uploading the whole graph each refresh period
    less load in the server

There are some things I still want to change, including experimenting with rrdtool, but displaying using jquery/flot which generates some very nice looking graphs.

I also need to daemonize the data acquisition bit, probably using daemon and some logging to wrap the datalogger.

There were a couple of omissions in the install details as I had to get some jgrid files to make it all work.

The temperature shows what it is at the server/inside as that is where the monitor it.

The transmitter is quite powerful and can blast over 10m from within full a metal enclosed fusebox. I suspect the 433MHz RF is coupling on the house wiring, otherwise it probably wouldn’t transmit very well. I originally extended the transmitter antenna, expecting it not to work very well, but found that it was unnecessary.

Comments Off :, , , , , more...

Using WinCE5.0 drivers on WinCE4.2

by on Feb.09, 2010, under WinCE

Since wince 4.2 is quite old and not that well supported by OEM device manufacturers, it is often hard or impossible to get drivers for wince4.2 for these devices.

However the API into coredll and other parts of the wince system libraries is, if not identical, then almost identical.

I had an instance recently where I needed to make a USB wifi device work with wince4.2. After doing some research, I chose a ralink 2471W based device. However it came with a wince5 driver. Binary only of course.

Looking at the driver dll, all the imported functions were available except 1 in the ndis.dll, that being NdisQueryPacket. In wince4.2, this fucntion is provided by a #define, but in wince5 it is a instantiated function.

The solution is to compile the following code to an obj, and use the lib32 to add it to ndislib.lib in the private tree.

// local modded copy of ndis.h
#include "ndis.h"
#include <pkfuncs.h>

OUT PUINT _PhysicalBufferCount OPTIONAL,
NdisQueryPacketDef(_Packet, _PhysicalBufferCount, _BufferCount, _FirstBuffer, _TotalPacketLength);

Also add the export definition to the end of ndis.def so that it becomes exported when ndis.dll is built with the system.

Finally, remember to put these 2 files back in the private tree where you got them from.

Now when the system is rebuilt with platform builder, the new ndis.dll will contain this extra function, thus allowing the USB wifi driver to function perfectly without modification.

Comments Off :, , , , , more...