i have a variety of gear that I attach to my server in order to monitor and control the home. As is the fashion these days, it’s a USB device that has a serial port on the end of it.
However as the home control software runs on a virtual machine on the main server, the real hardware has to be pushed through to the virtual environment. Some/most virtualization platforms allow you to assign real ports to virtual ports, but running the lowly VMWare Server I had to come up with another solution. Also, pushing the link across the network is preferable as it means the hardware could also be located on a remote device like a Bifferboard, with all the important software still running on the server.
For this I used Socat from http://www.dest-unreach.org/socat/
I knocked together a small script that could be run on either the host or guest, and it would run the right commands depending on the hostname of the machine it was run on.
#!/bin/bash
if [ `hostname` = “flat” ]; then
echo “This is flat – the host”
socat -v tcp-l:54321,reuseaddr,fork file:/dev/ttyS0,nonblock,waitlock=/var/run/ttyS0.lock &
elif [ `hostname` = “homeauto” ]; then
echo “This is homeauto – the guest”
socat -vvv pty,link=/tmp/vmodem0,waitslave tcp:172.24.32.5:54321 &
fi
exit
After that, make it executable, stick it somewhere safe, and then call it from /etc/rc.local or wherever suits you.
Recent Comments