genielabs / HomeGenie

HomeGenie, the programmable automation intelligence
https://homegenie.it
GNU General Public License v3.0
392 stars 155 forks source link

CM15PRO and DS10 security sensor error #98

Closed chrispazz closed 8 years ago

chrispazz commented 9 years ago

Using a CM15Pro to catch X10 security RF codes from DS10 sensors, it seems not to address correctly all units. Doing some debug: when receiving RF code:

5D 29 D7 D8 00 FF 74 00 (sensor 1 with address D7)

or code

5D 29 A7 A8 04 FB 13 80 (sensor 2 with address A7)

HG always map both to address 110:

11:33:01.406 PM X10 RF debug a=110 fn=84 Contact_normal_min_DS10A 122 HomeAutomation.HomeGenie.Automation 11:32:58.5 PM X10 RF debug a=110 fn=04 Contact_alert_min_DS10A 122 HomeAutomation.HomeGenie.Automation 11:32:32.479 PM X10 RF debug a=110 fn=04 Contact_alert_min_DS10A 122 HomeAutomation.HomeGenie.Automation 11:32:22.125 PM X10 RF debug a=110 fn=80 Contact_normal_max_DS10A 122 HomeAutomation.HomeGenie.Automation 11:32:08.868 PM X10 RF debug a=110 fn=00 Contact_alert_max_DS10A 122 HomeAutomation.HomeGenie.Automation 11:31:35.50 PM X10 RF debug a=110 fn=80 Contact_normal_max_DS10A 122 HomeAutomation.HomeGenie.Automation

so I think there is a bug in this section of SC9000 program source:

 var binaddress = Convert
                      .ToString(int.Parse(address, System.Globalization.NumberStyles.HexNumber), 2)
                      .PadLeft(8, '0')
                      .Substring(4, 3)
                    .ToCharArray();
     Array.Reverse(binaddress);
     var straddress = new string(binaddress);
     Program.Notify("X10 RF debug", "a=" + straddress.ToString() + " fn=" + function + "\n" + fnvalue);      

     address = Convert.ToInt32(straddress, 2).ToString();
  module = sc9000Modules.WithAddress(address).Get();

Thank you

genemars commented 8 years ago

X10 RF Security codes decoding is now a built-in feature of both the XTenLib and W800RF32 libraries.