Windows .bat to format x10 (x-10) cm11a output
[page last modified 2/9/2018]

This is a cmd script (.bat) to monitor and output x10 powerline commands seen by a cm11a device.  It requires the 6k command line tool phcom.exe to handle serial port transactions -- the C phcom.exe source is available here: phcom

I admit the .bat file is an ungodly hack... but it does work.  Example of its output:

   C>phcm11a .
   phcm11a Fri 02/09/2018
   16:03 m8 m+On i8 i+On m12 m+Off m2 m+On
   16:09 i8 i+Off o5 o+On o6 o+On o7 o+On o8 o+On
   16:10 o1 o+On o2 o+On o3 o+On o4 o+On o+AllUnitsOff

I've had this running on a server for six months now, logging all x10 activity in my house to a file accessible from the web.  The cm11a is connected to the server via a USB<->serial dongle.  Essentially I run, when my server boots:

   start /min cmd /k "phcm11a . >>x10log.txt"

The running .bat takes practically no cpu, since it's waiting for a byte to come in from the serial port 99% of the time.

Over the months I've added a couple options that are enabled by specifying optional 2nd and 3rd arguments (the 1st argument is required; it's the serial port number).

The 2nd argument specifies the name of a file that holds a 1-line list of the x10 devices that are currently on.  This file is continuously updated.  I point this to a file on a server RAM disk so it's quick to update.  Also that volume is shared on my network, so other computers can check what devices are on.  An example of the contents of that file:

   m2.m8.k4.i8.#.
Each device code is followed by a period, and the list is terminated by a dummy entry of a pound sign followed by a period.  If no device is on the file contains only a pound sign followed by a period.  The house+unit codes are stored in the order their state last changed (not alphabetically).  In the example above, i8 was the last device to be turned on.

The 3rd argument specifies the name of a .bat file to be called every couple seconds.

If the 3rd arg is specified a 2-second timeout is used when reading data from the serial port.  When a timeout occurs, the 3rd arg .bat file is called.  This allows something to be done every couple seconds... what that is depends on your needs.  The serial port is closed during the .bat file call, which means communicating with the cm11a is permitted.

I use the 3rd argument to check my mailserver for remote commands.  I have an x10 firecracker inline with the cm11a (ie. sharing the serial port).  My .bat file issues x10 commands via the firecracker, if any are queued.  This allows me, for instance, to send a text to my house phone number to turn on my central heater.


Change Log

Version 1.3 released 10/8/2018  Fixed bug causing immediate fatal exit if 2nd arg was unspecified.

Click here to download  phcm11a181008.zip


Version 1.2 released 2/9/2018  Initial release.

Click here to download  phcm11a180209.zip


Widget is loading comments...

You are visitor 955       Go to Home Page


phcm11a 1.3: Display CM11A output. 10/8/2018 paulhoule.com Loops forever echoing X10 addrs/funcs that come in from CM11A. 1st arg= port number 1-n, or . to use the highest COM port. {2nd arg}= text status file [1 line] of currently on devices {3rd arg}= .bat to call between CM11A polls [minimum once per 2 sec]