Author Archive

Fix Unable to connect to xend: Connection refused. ExpatError: no element found

The error message

Unable to connect to xend: Connection refused. Is xend running?

can be caused by a number of issues, but if your xend.log contains lines regarding syntax, such as:

[2012-01-23 11:33:37 5670] INFO (SrvDaemon:227) Xend stopped due to signal 15.
[2012-01-23 11:33:38 6427] INFO (SrvDaemon:332) Xend Daemon started
[2012-01-23 11:33:38 6427] INFO (SrvDaemon:336) Xend changeset: unavailable.
[2012-01-23 11:33:38 6427] ERROR (SrvDaemon:349) Exception starting xend (no element found: line 1, column 0)
Traceback (most recent call last):
  File "/usr/lib64/python2.6/site-packages/xen/xend/server/SrvDaemon.py", line 341, in run
    servers = SrvServer.create()
  File "/usr/lib64/python2.6/site-packages/xen/xend/server/SrvServer.py", line 251, in create
    root.putChild('xend', SrvRoot())
  File "/usr/lib64/python2.6/site-packages/xen/xend/server/SrvRoot.py", line 40, in __init__
    self.get(name)
  File "/usr/lib64/python2.6/site-packages/xen/web/SrvDir.py", line 84, in get
    val = val.getobj()
  File "/usr/lib64/python2.6/site-packages/xen/web/SrvDir.py", line 52, in getobj
    self.obj = klassobj()
  File "/usr/lib64/python2.6/site-packages/xen/xend/server/SrvNode.py", line 30, in __init__
    self.xn = XendNode.instance()
  File "/usr/lib64/python2.6/site-packages/xen/xend/XendNode.py", line 1140, in instance
    inst = XendNode()
  File "/usr/lib64/python2.6/site-packages/xen/xend/XendNode.py", line 158, in __init__
    self._init_PPCIs()
  File "/usr/lib64/python2.6/site-packages/xen/xend/XendNode.py", line 270, in _init_PPCIs
    saved_ppcis = self.state_store.load_state('ppci')
  File "/usr/lib64/python2.6/site-packages/xen/xend/XendStateStore.py", line 104, in load_state
    dom = minidom.parse(xml_path)
  File "/usr/lib64/python2.6/site-packages/_xmlplus/dom/minidom.py", line 1915, in parse
    return expatbuilder.parse(file)
  File "/usr/lib64/python2.6/site-packages/_xmlplus/dom/expatbuilder.py", line 926, in parse
    result = builder.parseFile(fp)
  File "/usr/lib64/python2.6/site-packages/_xmlplus/dom/expatbuilder.py", line 211, in parseFile
    parser.Parse("", True)
ExpatError: no element found: line 1, column 0

there is a good chance your xend database (stored, intuitively, in python syntax…) is suffering from corruption.

It is safe to remove the database but best practice to back it up so rename the directory:

# mv /var/lib/xend /var/lib/xend.bak
# /etc/init.d/xend restart

The Telus LG Optimus One (P500h): Not The Worst Thing Ever

About a year ago I shared my nightmarish adventure on the Keybo2 with you. It’s finally dying and I’ll be moving soon so I decided it was high time for a new phone. In my time with the Keybo, Telus and Virgin began offering actual smartphones on their prepaid plans. Unfortunately, Telus is the only carrier with a true one-number-unlimited feature which I need to tunnel all of my calls through a VoIP incoming/dial-out gateway for unlimited North America calling and great justice.

I was a little wary given my caged experience on the keybo; I expected captive portals and locked down features abound. I talked myself into it though, realizing if I really liked it I would probably return it, drop all the VoIP buggery and get a real plan with an incumbent provider. Imagine my delight when I turned it on and:

  • Connected to my access point
  • Downloaded an SSH client from the REAL android market for FREE
  • Created a VPN and shelled into a server
  • Browsed a bunch of websites
  • Installed and ran a terminal emulator
  • Enabled built-in mobile hotspot (tethering)

At this point I knew I was in love; even though the prepaid data on Telus is crap ($10/250MB), totally unrestricted wifi makes up for that by letting one sync and cache certain apps before heading out. Kudos to Telus for embracing tethering; to tether the Keybo you have to unlock the service menu and grab your PPP credentials then use dial-up modem emulation over BlueTooth or USB.  Unfortunately, the terminal emulator doesn’t really give you any access to your phone unless you install a custom (rooted) ROM. I’m two weeks in and haven’t needed to root my phone yet but if the urge arises expect another article. Interestingly, the NSA released SE Android yesterday but at present it looks like it must be built from source and probably won’t be very noob-friendly for a while to come.

Here are the specs, courtesy of GSMArena:

2G Network GSM 850 / 900 / 1800 / 1900
3G Network HSDPA 900 / 2100
Announced 2010, July
Status Available. Released 2010, October
Dimensions 113.5 x 59 x 13.3 mm
Weight 129 g
Type TFT capacitive touchscreen, 256K colors
Size 320 x 480 pixels, 3.2 inches (~180 ppi pixel density)
Alert types Vibration, MP3 ringtones
Loudspeaker Yes
3.5mm jack Yes
Card slot microSD, up to 32GB, 2GB included
Internal 170 MB user available, 512 MB RAM
GPRS Class 10 (4+1/3+2 slots), 32 – 48 kbps
EDGE Class 10, 236.8 kbps
Speed HSDPA 7.2 Mbps
WLAN Wi-Fi 802.11 b/g, Wi-Fi hotspot
Bluetooth Yes, v2.1 with A2DP
USB Yes, microUSB
Camera  3.15 MP, 2048×1536 pixels, autofocus
 Geo-tagging, face and smile detection, Beauty Shot
Video Yes, VGA@18fps
Flash No
OS Android OS, v2.2 (Froyo), upgradable to v2.3
Chipset Qualcomm MSM7227
CPU 600 MHz ARM 11
GPU Adreno 200
Sensors Accelerometer, proximity, compass
Messaging SMS (threaded view), MMS, Email, Push Email, IM
Browser HTML
Radio Stereo FM radio
GPS Yes, with A-GPS support
Java Yes, via Java MIDP emulator
Features - Social networking integration
- Google Search, Maps, Gmail
- YouTube, Google Talk
- DivX/Xvid/MP4/H.264/H.263/WMV player
- MP3/WAV/WMA/eAAC+ player
- Document viewer/editor
- Organizer
- Voice memo
- Predictive text input

Although the camera’s resolution is no improvement over the Keybo I’m thrilled to finally have automatic, mechanical focus. Now instead of snapping 50 shots to get one decent one I’m down to something like 5. My Optimus shipped with Android 2.3 and a now-defunct app called the LG App Advisor.

Now that I had become introduced to my new toy it was time to get that totally badass animated weather wallpaper HTC Sense UI users have. To do this without purchasing Beautiful Widgets we first replace the default launcher (LG’s kind of sucks anyway) with GO Launcher EX. Then download GO Weather, both available through the Android Market. GO Weather is a beautiful (literally) piece of software that provides three interfaces:

App – This sits in your app tray and has its own video theme. Opening the app provides detailed weather information and updates the weather data.
Widget – There are four different sized widgets that can be included in your launcher; depending on the skin you choose they may display different things.
Live Wallpaper – Set your launcher’s background to the GO Weather Live Wallpaper and download a video theme to get a similar effect as the App.

Next I wanted to grab a few apps that would be handy around the city. TTC Alerts  is probably the neatest, most useful app I have installed so far. When a diversion, delay or cancellation happens on Toronto’s bus, subway and light rail system I am notified by a vibration and red TTC icon in my status bar. Dragging down the status bar gives me the details. When the issue clears up and everything is moving smoothly once more the icon turns green. Essential for anyone who relies on The Rocket.

Another sweet app for TTC users is Transit Now Toronto. You can use your GPS to find the closest bus stop and plan your route. The free version of this app does not support the Alerts function but the TTC Alerts app discussed above makes this sort of moot. If you’re lazy like me you may also like the TTC Subway Efficiency Guide which helps users pick the right place to stand on platforms so they are better situated to stairs and escalators at their destination. Toronto PATH Map is a pocket-sized map of the world’s largest underground shopping complex.

Being a man of the province I also downloaded Go Mobile from Ryerson University. Go Transit is Ontario’s inter-municipal transit system, it operates a combination of diesel-electric locomotives and coach busses to interconnect the towns and cities of Southern Ontario. My biggest complaint about this app is it requires a data connection to even get to the main menu. I feel the bus and train schedules could at least be cached daily. A minor gripe is that it is impossible to plan a route end-to-end where there is a connecting bus or train.

Speaking of caching, data is going to cost a lot on a prepaid plan so anything we can grab while at home or near a hotspot is golden. Nowhere can I see this being more beneficial than with GPS navigation. The apps that came loaded on my droid – and many of the third party apps out there -  rely on a data connection and Google Maps. Fortunately, MapDroyd has you covered: you can download a pre-compiled map of a given geographical area to your SD card .

That brings me to entertainment: with all of the weather and TTC updates and bells and whistles going on in the background non-stop I expect to be chewing through my 250MB quota without even using the connection. Obviously, browsing youtube is not going to be an option on the road. In addition to audio and video files off the PC I have found these interesting apps which will let you store their content for offline viewing:

  • The Toronto Star – News notifications, background synchronization and off-line viewing of one of Canada’s most respected news outlets.
  • TED Air – Download videos of TED talks to watch at any time. Very slick looking but also very crashy. I have had a _lot_ of problems with this one.

To track my data usage I’ve been using DroidStats because it’s one of few which track wifi in addition to 3G. DroidStats also comes with 4 different sized widgets to keep you informed of your quota usage on the launcher.

I’ve decided to keep this phone for the time being. The wifi combined with $10 data plan and one-number-unlimited still make it more economical for me to put up with routing my calls through VoIP than ponying up for a real phone on a proper data plan. It’s a big shock for me, giving Telus a good review but I’m so happy to finally have a cellphone that DOES things.

For $99 I have no regrets. This time.

Everything I Wanted to Tell You About X10 Home Automation

…But Didn’t Have the Time to Say

I had been meaning to chronicle my tinkering with Home Automation in the same way I have been documenting my ongoing experience with Electronic Cigarettes. Unfortunately, I never found the time to post as I made my installations and I will be moving soon, leaving most of them behind. I want to make sure the 100th post on foxpa.ws has substance so without further carry-on may I present unto you my complete experience with X10:

What Are X10 and Home Automation?

Home Automation is the art of modifying and integrating household systems (lighting, HVAC, etc.) to respond to events automatically (timers, security sensors, etc.) or methods of control not already provided (computer, remote control, etc.).

X10 is a power-line and wireless communications standard for home automation. Developed in 1975, X10 is widely deployed and devices that use it are relatively inexpensive.

How Does X10 Work?

X10 devices communicate digital information over your house’s power lines at the zero-crossing point of the (60 Hz) AC current by either sending a 1ms long 120 kHz pulse to represent a 1 bit or not sending anything to indicate a 0. Each device is configured with a 4-bit “house” code (A-P) and a 5-bit “key” code (1-16, always ends in 0). Additionally, there are 16 global commands which are also 5-bits and always end in 1. The house code is intended to prevent conflicts with neighbouring houses or units but is more commonly used to group different sets of devices together in larger installations.

House Code Device Code Binary Value Function Binary Value
A 1 0110 All Units Off 0000
B 2 1110 All Lights On 0001
C 3 0010 On 0010
D 4 1010 Off 0011
E 5 0001 Dim 0100
F 6 1001 Bright 0101
G 7 0101 All Lights Off 0110
H 8 1101 Extended Code 0111
I 9 0111 Hail Request 1000
J 10 1111 Hail Acknowledge 1001
K 11 0011 Pre-set Dim (1) 1010
L 12 1011 Pre-set Dim (2) 1011
M 13 0000 Extended Data Transfer 1100
N 14 1000 Status On 1101
O 15 0100 Status Off 1110
P 16 1100 Status Request 1111

To grab the attention of the devices all commands are preceded with a start code, 1110. Since the idle data-stream consists of an absence of 120kHz pulses or 0s, devices can be sure if they see three 1s in a row that a command is being sent and they are not simply picking up noise. To improve reliability all commands are sent twice, with a three cycle delay in between. An X10 frame might look like this:

1110  0110  01100 000   1110  0110  01100
start house  key  pause start house  key

X10 also has a radio frequency specification that lets remote controls and computer attachments send X10 commands via a radio receiver plugged into the house wiring.

My Installaton

My installation started small and increased in stages as I became more aware of the capabilities of X10. My first order was for:

  • TM751 Mini Transciever – This is the device that takes wireless X10 signals and repeats them on the wire.
  • HR12A PalmPad Remote Control – These are large RF “clickers”
  • KR22A Credit Card Controller – A less bulky RF controller that only covers 4 units
  • AM466 3 Pin Grounded Appliance Module – A grounded module is slightly more expensive than a 2-prong “lamp” module
  • WS12A 3-Way Dimmers – I didn’t use their 3-way capability. Annoying one-pole switch requires double tap to adjust light in opposite direction

As you can see, some modules are designed to be wired into the electrical box and others are designed to plug into pre-existing sockets. There are some light modules that even screw into the Edison-type connector typical North American light bulbs use for easy installation in fixtures and lamps. Maliciously, these dimmers have cover plates which are shaped to provide the appearance of rocker switches. In truth, they are one-poll switches. A single tap to turn the light on or off, hold to dim or brighten the light or – this is my favourite part – hold to see if the current “direction” is dim or brighten, release, very quickly press and hold to go in the opposite direction.

It should be noted that most dimmers – including the ones I purchased – do NOT work with fluorescent lighting. I use the 20A rated on/off wall-switches which are usually advertised for appliances where there are fluorescent lights or fans. The drawback to this is every few moments the CFL may flicker very dimly while the switch is “off” due to the switch itself drawing a small amount of current. The other caveat in using the 20A switches is that they must be wired into both hot and neutral; this presents a problem in electrical boxes where both are not accessible. It is perfectly safe to use a 20A rated switch in a 15A circuit; overload protection is provided by the breaker which only means the switch has leftover potential capacity on a 15A circuit.

Here’s a shot of the dimmer and 20A switch I installed in my ensuite. The dimmer is rated for 500watts so it runs my 4x100Watt vanity strip perfectly. I’m sure the ladies can appreciate the kind of light range that can give you in a bathroom. The fan, being an induction-driven appliance, does not like TRIAC-based dimmers so it goes on on a simple 20A switch (WS13A).

It wasn’t long before I noticed there were intermittent problems getting the signals across to certain parts of the house from the RF receiver. Many household devices, particularly: televisions, PCs and uninterruptible power supplies will absorb X10 signals passing through them. The most effective solution is to put them on a filter. X10 filters block the frequency X10 devices use from entering the connected device(s) at the wall. Unfortunately, while the modules in the first two pictures averaged $10 each filters are much more expensive.

An XPPF 5 amp plug-in filter (far below) runs upward of $15 and an AF120 15 amp filter (above) runs upward of $35. Given I use two 1400VA UPSes for my workstation and networking I was forced to get the full 15A filters. These come with a screw hole in a tab at the top aligned so that the screw of a standard receptacle faceplate can be used to secure the filter into the wall. Given its size and weight, I highly recommend doing this. Smaller, singular appliances should be fine with the 5A rated units but check your documentation. I have seen folks out there wire what is intended to be an inline (in the wall) 20A filter into a power strip and use this instead. It is cheaper than the 15A plug-in filters; it is also ballsier.

It didn’t take long for me to get interested in the security applications of X10. To start off I purchased a security console (PS561) and two cheap magnetic sensors (DS10A). The security consoles seem to operate using a proprietary (non-X10 specification) wireless protocol. Sensors and remotes are configured using two-button authentication; first the console is put into a programming mode then the test button or equivalent is pressed on the device to be registered. This particular unit will dial up to 4 numbers until one of the dialled people presses 0 to confirm they are listening to the call. At that point one can listen in on what’s happening in the vicinity of the console. This is severely hindered by the fact that there are two piezoelectric sirens mounted in the same chassis going off at the same time (and optionally additional alarms).

Like an idiot I didn’t realize the console would not come with at least one controller. This set back installation by T+shipping.

The peizo sirens in the security console don’t penetrate much farther than the room it’s in if the door is closed. Apparently the solution to this is throwing more sirens at it. I purchased the X10 PowerHorn (SH10A) which can be installed anywhere in the house by plugging it into the mains. The security console is configured to send alternating on and off commands to a certain house and device code. The original purpose of this was to flash lights on and off to make your house more visible to law enforcement. The PowerHorn takes advantage of this by sitting on the same house and device code as your lights and waiting for a pattern of on and off codes to activate. This sort of brute-force approach has two major limitations: the PowerHorn will lag behind your security console when the alarm is tripped and if you turn the lights with the same code on and off too many times too quickly by hand you can easily produce a false positive. This happened to me twice at poorly chosen hours before I decided to live without the horn. It deactivates shortly after the alternating pattern ceases.

I find the door sensor I installed falls out of sync once every two months or so; this is inconvenient enough to make it not worth using. Often I just don’t have the time to re-program the unit when I’m on my way out the door.

  • XPPA Plug-In Filter Module – A grounded, 5 amp plug-in X10 signal filter.
  • SS13A 3 Unit + Dim RF Style Switch – A wireless X10 switch that can be mounted anywhere
  • SC546A Remote Chime – A doorbell-type module which responds to the ON command

To use the SS13A modules as doorbells I had to open them and slice out the rubber tab that produces the rocker-switch effect that makes one side of the button “on” and the other “off.” I then taped over the “off” contacts on the circuit board so no matter what side the button is physically pressed only the “on” command is sent.

The 15A filters helped my signal problems a lot but there was still the odd blip in service so I went ahead and bought two 5A filters to dick around with. The chimes take a simple on command and – contrary to some advertising – have only one, non-selectable “melody.” The wireless switches can be programmed to take any 3 consecutive key IDs and any of the 16 house codes. The bottom button is a toggle pad for bright and dim commands. The cool thing about them is they stick on to the wall using an adhesive backing and are thin enough to provide the illusion that they are the faceplate of a recessed electrical box without having to smash into the wall. They take a CR-32 battery in the bottom tray and communicate using the RF->mains receiver.

My final purchase was the MT13A Mini Timer. I had for some reason been under the impression that the PalmPad remote would be able to act as a timer, which was one of the main reasons I became interested in X10: it would be possible to automatically turn off the lights when I pass out with them on. I didn’t have the time to do anything really sophisticated with computer automation and I needed a new alarm clock so I ponied up, plugged it in and never touched it again. I’m sure it’s great, I just wouldn’t know.

Controlling X10 Devices with your Computer

Obviously the really sweet part about Home Automation is interfacing your house with your computer. For about $5 you can pick up a wireless transmitter called a FireCracker (CM17A) that works with standard X10 wireless receivers and takes instructions from a standard serial port. I have found that there is an issue with the internal timing on one of my USB-serial cables’ particular chips. The transmitter uses pins not normally used by serial devices to transmit data so it can be transparently daisy-chained with another serial device behind it. I have read that some USB-serial adapters drop one or more of these pins. If your USB-serial adapter does not seem to work with the transmitter be sure to do your research before selecting another one.

Other versions exist for USB which plug directly into the wall. I can only guess as to whether or not these use an embedded USB->serial adapter (linux compatible) or if they are intended for use with Windows based home automation software.

There are a couple of packages that can drive the FireCracker but I have only used bottlerocket

To compile on Gentoo run:

# emerge bottlerocket

Bottlerocket takes these options:

Usage: br [<options>][<housecode>(<list>) <native command> ...]

  Options:
  -v, --verbose                 add v's to increase verbosity
  -x, --port=PORT               set port to use
  -c, --house=[A-P]             use alternate house code (default "A")
  -n, --on=LIST                 turn on devices in LIST
  -f, --off=LIST                turn off devices in LIST
  -N, --ON                      turn on all devices in housecode
  -F, --OFF                     turn off all devices in housecode
  -d, --dim=LEVEL[,LIST]        dim devices in housecode to  relative LEVEL
  -B, --lamps_on                turn all lamps in housecode on
  -D, --lamps_off               turn all lamps in housecode off
  -r, --repeat=NUM              repeat commands NUM times (0 = ~ forever)
  -h, --help                    this help

          is a comma separated list of devices (no spaces),
                each ranging from 1 to 16
      is an integer from -12 to 12 (0 means no change)
     is a letter between A and P
    is one of ON, OFF, DIM, BRIGHT, ALL_ON, ALL_OFF,
                LAMPS_ON or LAMPS_OFF

For native commands,  should only be specified for ON or OFF.

In order to control the lights with a meta key on my mouse I had to wrap this in a little script so the KDE shortcut manager could reference it correctly:

mdma bin # cat x10on
#!/bin/bash
br -x /dev/firecracker k2 on

Where /dev/firecracker is, in my case, a symlink to /dev/ttyUSB0.

I’ve noticed that the device has little or no buffer; sending too many commands too quickly will cause the device to cease functioning, possibly temporarily. Unplugging and re-seating it seems to solve the problem every time. The lack of built in buffer or command queue (indeed, even the ability to ignore commands while one is being transmitted) is something which should probably be addressed in controller software or front-ends.

Neat Stuff I Wanted to Play With But Never Got the Chance

The coolest part about X10 if you’re a real geek is its ability to remotely turn on or off anything that has an on or off switch through your house’s existing wiring.

The so-called universal modules allow you to wire directly into an existing switch. They can be configured for normally open or normally closed operation. This means that you can control virtually any device which does not natively support X10 or remote control like, say, your old garage door opener. Or a hydroponics pump.

Just sayin'.

Coupled with computerized control it would not be hard to make a web interface that controls your coffee maker, or other sinister devices.

Conclusions

Since most houses have their three-phase input split into two two-phase segments signals from one side of the house may need to travel all the way down to the transformer at the end of the road then back into the house, by this time severely degraded. To remedy this a repeater can be installed across the phases at the breaker panel (about $30) but this is “serious business” and should only be performed by a real electrician. The safer alternative is a $100 (depending on three or four prong configuration) repeater that plugs into the dryer or stove outlet.

I look forward to trying one of the newer home automation protocols in the future. X10 is slow to the point of agony. To dim a 100W light bulb from maximum to minimum takes about a minute of repeat pressing on the buttons. The controllers either do not auto-repeat when the buttons are held down or they repeat so quickly the messages become garbled on the wire. In support of this theory, I have found that clicking the dim button then waiting for the reaction before clicking it again is far faster than mindless rapid clicking. This, combined with the poor quality of the entry level security modules and lacklustre signal performance make X10 a labour of love in my most humble of opinions.

 

Return top
foxpa.ws
Online Marketing Toplist
Internet
Technology Blogs - Blog Rankings

Internet Blogs - BlogCatalog Blog Directory

blogarama - the blog directory
Technology blogs
Bad Karma Networks

Please Donate!


Made in Canada  •  There's a fox in the Gibson!  •  2010-12