Hi cewongq,
Here is some stuff to get you started, I'll send you a zip as well.
1) Download and install the ActiveX component hspi_CM19A_USB.ocx from
http://x10.patterson.cx/x10/2) To work on a PC, you must also install the Firecracker drivers
from
http://www.x10.com/support/support_soft1.htm I used Version 2.0.0.82 xfire.exe
Create a form in VB (sorry, don't know C)
Add a reference to the ActiveX component hspi_CM19A_USB.ocx
At the top of the module add
Dim WithEvents oFC As hspi_CM19A_USB.cFirecrackerUSB
'though you can leave out withEvents since they haven't been overly useful
' In the Form_Load sub, add:
Set oFC = CreateObject("hspi_CM19A_USB.cFireCrackerUSB")
debug.print "Is the CM19a Connected? " & oFC.Connected
' add some buttons that call the subs below
' housecode is "A", or "B",... etc
' devicecode is 1, 2, etc
Sub lightOn(housecode As String, devicecode As Byte)
oFC.command = cON
oFC.housecode = housecode
oFC.devicecode = devicecode
oFC.SendCmd
End Sub
Sub lightOff(housecode As String, devicecode As Integer)
oFC.command = cOFF
oFC.housecode = housecode
oFC.devicecode = devicecode
oFC.SendCmd
End Sub
~~~~~
cON and cOFF are enums included in hspi_CM19A_USB.ocx
So instead of the syntax of "sendrf A1 on", the syntax here is to
create an object. Then for that object,
set the command property, the housecode property, the devicecode property,
and THEN use the method SendCmd
A little awkward, but it works.
Let me know if that helps / if it works for you.