Table of Contents
Absence of the CM15A
At first blush, it does not seem to matter much if the ActiveHome SDK does not report the absence of the CM15A when sending commands to it. If the device is not connected, it does not reply to a send message and a visual check should let a person see if it is connected to the computer!
As for the first comment, it may not be acceptable to turn a light on or off just to check if there is a CM15A at the end of the USB cable. As for the second, you may be interested in writing some sort of a server that is connected to the CM15A and can be reached on a local network or over the Internet. The user of a client application could not visually check for the presence of the CM15A.
To investigate the problem a little further, please download the expanded application
cm15.exe.

found here (cm15.zip, 8861 bytes, 2013-08-09).
Using Other TActiveHome Methods
The TActiveHome class contains two procedures that on the face of it might tell us if a CM15A is connected or not:
Unfortunately, both functions return an empty variable in all cases! You can verify this by clicking on Test EnumerateInterfaces and Test GetInterfaceName with the CM15A not connected and then connected. There is no difference.
Similarly the ControlInterface
and DefaultInterface properties of
the component are always assigned. Or perhaps more to the point, they
are assigned as long as the ahsdk.dll is
found, whether a CM15A is connected or not.
Querying the State of a Device
The CM15A keeps tabs on the state of
X10 devices. By using the command queryplc
it is possible to know a device's status : on or off
and dim/bright level if applicable. To find out if a device
is on or off, the command sent is
where res is an OleVariant variable. It
appears that only three
results are possible :
res = -1 : the
CM15A is not connected
res = 0 : device A4 is off (and the
CM15A is connected)
res = 1 : device A4 is on (and the
CM15A is connected).
Clearly this command could be used to test for the presence of
the CM15A. Here is a very simple implementation for a method
to be added to the public declaration of the TActiveHome
class:
Another, rather more complicated approach is to send a
hailrequest and see if an answer comes back. The test application shows
how; look at procedure TForm1.Button2Click(Sender:
TObject);. It would be more difficult to include that in
the component. Since TransceiverPresent seems to work, I have not
looked at this possibility.
The complete modified imported type library can be downloaded here: ActiveHomeScriptLib.pas (12793 bytes, 2013-07-15).
What's Next?
This is the end of this discussion about using a CM15A with Delphi in Windows. But that is by no means all there is to know about that device. For example, error messages from the library, ahscript.dll, indicate that it wants to see one of the following commands
sendplc
sendrawplc
sendrf
sendsecurerf
sendsecurehomecontrolrf
queryplc
sendir
At least four of those were not used in cm15.exe. Trying
"sendir a1 on" with the application's send anything function returned
an error message
ActiveScriptError: Expecting SendPLC [address] [command] [code] [keystate] [Transmit] [Delay]
that indicates that sendplc is much more complex than seems.
Unfortunately, getting information about the CM15A and ahsdk.dll
is not easy. I'll mention two sources, but they are from the Linux
world and, consequently, are not concerned with the ActiveX script server:
2. Brian Uechi's mochad ( http://sourceforge.net/apps/mediawiki/mochad/index.php?title=Main_Page) is a Linux deamon that talks directly to the CM15A over the USB connection. In essence, it replaces the ActiveX component. It works on a Beagleboard and on a Raspberry pi. Do an Internet search on "mochad raspberry pi" for many tutorials on getting mochad up on that surprising little computer on a chip. There are a couple on this site also.

Part 3 - Listening to the CM15A