Take the 2-minute tour ×

I am connecting a currentcost electricity monitor to my ubuntu server and am using the method to connect as described here ...

putting your watts on the web


/opt/bin/head /dev/ttyUSB0 -n1 | /bin/grep '<ch1><watts>' | /bin/sed -e s/\<ch1\>\<watts\>/\ / | /opt/bin/cut -d' ' -f2 | /opt/bin/cut -c1-5

Now, I am also having the same problem as described here ... putting your watts on the web, part 2

The data hangs where the head command pulls the data. It works for a while then randomly stops.

Firstly, I would like to know whether I can virtually unplug and reinsert the USB device /dev/ttyUSB0, so I can at least fix the problem remotely when it happens.

Secondly, what would be the best method of investigating the cause? Alternatively, should I be looking at writing a C program to do this instead? I know very little C, so this would be a challenge.

share|improve this question
are you 100% sure that the head command is even getting output from the device when it hangs? You may need to just run that head command alone (with no arguments) for a while to ensure you know the output that happens under all circumstances –  Mike Pennington May 10 '11 at 9:57
add comment

1 Answer

For a C snippet that (purportedly) equals an unplug/replug cycle, see here.

share|improve this answer
add comment

Your Answer


