How are we supposed to send RAW commands?

Started by rockinthesixstring, November 11, 2012, 05:12:45 PM

Previous topic - Next topic

rockinthesixstring

Quote from: spval on November 12, 2012, 02:41:44 PM
You had better do all of your research before the trial period ends !
I have always put up with the delay when stringing multiple commands together. In fact, I padded them with thread.sleep values in between each command, just to make sure that I didn't lock up the interface. If you have some sort of x10 controller and you set two devices with different codes to go on at the same time, is there any delay ?. I just have the sdk installed and no AHP. You should be able to create anything that AHP can do.


Yeah, I'm gonna cut my teeth into this tonight when I get off work. I'll run the AHP software through the sniffer and see what comes out. AHP doesn't "seem" to have a delay in my setup. When I say "Living Room Lights On", my lamp module and my two light switches appear to receive and execute the commands at the same time.

rockinthesixstring

PS: the lite version of that software isn't too expensive if I had to purchase it beyond the 14 days... thanks for the recommendation.

spval

It is great software. Good luck with the project.

rockinthesixstring

Interesting followup... I suppose I'm still not fully understanding .

Here's the output from running A1 through to B16, all with "on" commands.


04 66 06 62
04 6e 06 62
04 62 06 62
04 6a 06 62
04 61 06 62
04 69 06 62
04 65 06 62
04 6d 06 62
04 67 06 62
04 6f 06 62
04 63 06 62
04 6b 06 62
04 60 06 62
04 68 06 62
04 64 06 62
04 6c 06 62
04 e6 06 e2
04 ee 06 e2
04 e2 06 e2
04 ea 06 e2
04 e1 06 e2
04 e9 06 e2
04 e5 06 e2
04 ed 06 e2
04 e7 06 e2
04 ef 06 e2
04 e3 06 e2
04 eb 06 e2
04 e0 06 e2
04 e8 06 e2
04 e4 06 e2
04 ec 06 e2


Notice how A1 - A16 all end in "06 62"? I was under the impression that "06 62" was the equivalent of "on"
however
Notice how B1 - B16 all end in "06 e2"? That must mean that there's a different "on" trigger for each house code?

It's the same with "Off" codes... A1 - A16 end in "06 63", where B1 - B16 end in "06 e3"...


spval

Your observations are correct. Actually, the ending "2" is the "on" and an ending "3" would be "Off". Fun, eh ?


spval

#21
Did you ever get a chance to read the x10 protocol info. There is a outline of what the hex codes stand for. For instance, the beginning "04" is probably always constant (a checksum or header), so you wouldn't have to deal with it.

Have a look at this url:

http://software.x10.com/pub/manuals/cm11a_protocol.txt


spval

Here is the code to receive an event, just in case you didn't have it already:

C#:
using ActiveHomeScriptLib;
using System.Threading;
public class Form1
{
   ActiveHomeScriptLib.ActiveHome ActiveHomeObj;

   private void  // ERROR: Handles clauses are not supported in C#
Form1_Load(object sender, EventArgs e)
   {
      ActiveHomeObj = new ActiveHome();

   }


   public void  // ERROR: Handles clauses are not supported in C#
ActiveHome_RecvAction(object bszRecv, object vParm1, object vParm2, object vParm3, object vParm4, object vParm5, object vReserved)
   {
      TextBox1.Text = (bszRecv + "  " + " " + vParm1 + " " + vParm2 + " " + vParm3 + " " + vParm4 + " " + vParm5) + Constants.vbCrLf;
      TextBox2.AppendText(TextBox1.Text);
   }


   private void  // ERROR: Handles clauses are not supported in C#
Button1_Click(object sender, EventArgs e)
   {
      ActiveHomeObj.SendAction("sendrawplc", "04 66");
      // CM15A replies with 0x55  (always)
      ActiveHomeObj.SendAction("sendrawplc", "06 62");
      // turn A1 On
      // CM15A replies with 0x55  (always)
   }


   private void  // ERROR: Handles clauses are not supported in C#
Button2_Click(object sender, EventArgs e)
   {
      ActiveHomeObj.SendAction("sendrawplc", "04 66");
      // CM15A replies with 0x55  (always)
      ActiveHomeObj.SendAction("sendrawplc", "06 63");
      // turn A1 Off
      // CM15A replies with 0x55  (always)
   }
}

VB:
Imports ActiveHomeScriptLib
Imports System.Threading
Public Class Form1
    Dim WithEvents ActiveHomeObj As ActiveHomeScriptLib.ActiveHome
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        ActiveHomeObj = New ActiveHome

    End Sub

    Sub ActiveHome_RecvAction(ByVal bszRecv As Object _
                      , ByVal vParm1 As Object _
                      , ByVal vParm2 As Object _
                      , ByVal vParm3 As Object _
                      , ByVal vParm4 As Object _
                      , ByVal vParm5 As Object _
                      , ByVal vReserved As Object) Handles ActiveHomeObj.RecvAction

        TextBox1.Text = (bszRecv & "  " & " " & vParm1 & " " & vParm2 & " " & vParm3 & " " & vParm4 & " " & vParm5) & vbCrLf
        TextBox2.AppendText(TextBox1.Text)
    End Sub
   

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ActiveHomeObj.SendAction("sendrawplc", "04 66")
        ' CM15A replies with 0x55  (always)
        ActiveHomeObj.SendAction("sendrawplc", "06 62") ' turn A1 On
        ' CM15A replies with 0x55  (always)
    End Sub

   
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        ActiveHomeObj.SendAction("sendrawplc", "04 66")
        ' CM15A replies with 0x55  (always)
        ActiveHomeObj.SendAction("sendrawplc", "06 63") ' turn A1 Off
        ' CM15A replies with 0x55  (always)
    End Sub
End Class

The first portion of that protocol page contained the basic x10 protocol that you needed, but the rest was written for a CM11A interface. I don't want you and your buddies at stackoverflow.com to get off on a wild goose chase.

rockinthesixstring

Yeah I appreciate this. The code that @AbdiasSoftware posted on my question is a little uh, overwhelming.

I know how to write code to execute the calls against the SDK, and I'm not at all worried about that part in my project.

All I was trying to do is find a correlation between the raw calls and the human readable calls, and write a function that would return the appropriate raw codes when the human readable codes are input.

Since I haven't found a way to string multiple raw codes together in a single call, this whole adventure might be moot. I might as well use the human readable codes.


   ahsdk.SendAction("sendplc", "A1 ON");
   //wait for a "0" response
   ahsdk.SendAction("sendplc", "A2 DIM 20");
   // rinse / repeat


To me, this looks ugly, and I was hoping that the `sendrawplc` would allow the equivalent of


    ahsdk.SendAction("sendplc", "[{A1 ON}, {A2 DIM 20]}");

rockinthesixstring

looks like my friends over at StackOverflow don't like my question :(

spval

I see one very small shortcut:
For stacked commands, if the HC and Function are the same, you can do a
ActiveHomeObj.SendAction("sendrawplc", "04 66");
ActiveHomeObj.SendAction("sendrawplc", "04 65");
ActiveHomeObj.SendAction("sendrawplc", "04 64");
ActiveHomeObj.SendAction("sendrawplc", "04 63");
ActiveHomeObj.SendAction("sendrawplc", "04 61");

followed by a single Function command:
ActiveHomeObj.SendAction("sendrawplc", "06 62");

I suppose this saves some time. Bottom line seems to be only one HC/Device per packet.

rockinthesixstring

This is what I needed


Housecode Device Code Binary Value Hex Value
A 1 0110 6
B 2 1110 E
C 3 0010 2
D 4 1010 A
E 5 0001 1
F 6 1001 9
G 7 0101 5
H 8 1101 D
I 9 0111 7
J 10 1111 F
K 11 0011 3
L 12 1011 B
M 13 0000 0
N 14 1000 8
O 15 0100 4
P 16 1100 C