Author Topic: CM11A - adding new lights...  (Read 35134 times)

jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
Re: CM11A - adding new lights...
« Reply #15 on: February 21, 2008, 08:44:59 am »
Dan-

I'm working on it now.. trying to get the checksum bug fixed as we speak :)

nite_man

  • NEEDS to work for LinuxMCE
  • ***
  • Posts: 1019
  • Want to work with LinuxMCE
    • View Profile
    • Smart Home Blog
Re: CM11A - adding new lights...
« Reply #16 on: February 21, 2008, 09:22:32 am »
Dan-

I'm working on it now.. trying to get the checksum bug fixed as we speak :)

Excellent! Finally we'll get a 100% working CM11 interface :)
Michael Stepanov,
My setup: http://wiki.linuxmce.org/index.php/User:Nite_man#New_setup
Russian LinuxMCE community: http://linuxmce.ru

jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
Re: CM11A - adding new lights...
« Reply #17 on: February 21, 2008, 05:28:52 pm »
It may take a little while (I'm a bit rusty on my C++) but I had a good first night working on this. Most of the time so far has been spent commenting all the code so I can follow it better, as well as setting up a development environment (there are some really helpful guys on IRC - thanks for the help - you know who you are). I'm just now starting to make changes to the code and see where it gets me. I'll post back when I actually get somewhere

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: CM11A - adding new lights...
« Reply #18 on: February 21, 2008, 05:47:40 pm »
way tou go Jon!!
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: CM11A - adding new lights...
« Reply #19 on: February 21, 2008, 07:47:46 pm »
jon,

I'm sure you've found this, but the message.cpp file I believe is where the checksum is calculated..

HTH

Dan
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: CM11A - adding new lights...
« Reply #20 on: February 22, 2008, 01:56:05 am »
Hey Guys:
Devicepoll.cpp Line 239, remove the '!'.
That fixes the polling! YAY

Tested and confirmed!

All the best,

Dan
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
Re: CM11A - adding new lights...
« Reply #21 on: February 22, 2008, 03:30:54 am »
Dan-

I found that too. Unfortunately I had to wrap up for the night and go to work (I'm working right now..)
Where I wanted to continue tomorrow is in Serial/SerialPort.cpp and take a look at CSerialPort::IsReadEmpty()
to make sure there wasn't a problem in there before removing the !
Anyways, good work! We were on the same track
« Last Edit: February 22, 2008, 03:52:40 am by jondecker76 »

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: CM11A - adding new lights...
« Reply #22 on: February 22, 2008, 07:30:30 am »
Ok Jon, I've committed my change, and now I'm seeing everything coming in NO problem.

FYI, I had to change the monitoring house code to C (only device I had).  So if you look into that a bit closer, keep me posted.

Great Stuff!

Regards,

Dan

The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
Re: CM11A - adding new lights...
« Reply #23 on: February 22, 2008, 08:07:04 am »
Dan

There should be no reson that I can see to change the Monitored house code from 0x06 (I'm assuming your talking about the hard-coded monitored house code in DevicePoll::SendClock()). The interface will receive on all house codes regardless of what the monitored house code is set to. The only time that function is called anyways is pretty much if the power goes out and comes back on, or when you first plug it in.

After a lot of reading, what the monitored house code appears to do is store the state of all devices for the specified house code. (So the CM11A has a 2-byte buffer, with the 16 bits representing on/off for all of the device code for the monitored house code). That way, when a power outtage occurs, the interface will send a timer request to the PC (0xA5) to resync the internal time clock, and set the house code to monitor states on.
After this point, if we send the CM11A a status request (0x8B), we can obtain the stored status of all the devices on the monitored house code.
(This is what I understand of it anyways, and I think i have a pretty good handle on it)

I don't believe LMCE uses this information anyways (though I haven't really looked yet), and even if it did, it would not be all that useful in the context of LMCE.

and on another note, I'm going to do some tests with motion sensors tomorrow :)
« Last Edit: February 22, 2008, 08:12:24 am by jondecker76 »

jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
Re: CM11A - adding new lights...
« Reply #24 on: February 22, 2008, 08:17:21 am »
I'm at work and don't have much time to look into it, but I couldn't help but to check on the monitored house code thing...
if you look at cmllaconsts.h, the status request byte (0x8B) isn't defined, so without looking into it further I would say that LMCE doesn't even support it (and really doesn't need to)

grba

  • Making baby steps
  • Posts: 2
    • View Profile
Re: CM11A - adding new lights...
« Reply #25 on: February 22, 2008, 08:19:40 am »

grba, could it be that those outlets are on different phases?


It's not it's on same phase. But work just fine and after 2-3 minutes start to switch on my lights. In other socket 3mtr from that one working fine.

jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
Re: CM11A - adding new lights...
« Reply #26 on: February 22, 2008, 01:11:58 pm »
dan -
I just got home after a 14 hour work night. I had a quick chance to test the change.
Polling does work - however there is still a problem. The latency of my X10 setup was about 1 second. Now, with the change, its anywhere from 5 to 12 seconds. I'm going to work on this today after I wake up - i need to get some sleep!


jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
Re: CM11A - adding new lights...
« Reply #27 on: February 22, 2008, 01:36:28 pm »
ok going to sleep for real this time..
X10 sensor causes and endless loop here:
Code: [Select]
do {
LoggerWrapper::GetInstance()->Write(LV_STATUS, "Reading the Upload Buffer Size...");

nread = serprt.Read((char*)&resp, 1, CM11A_READ_TIMEOUT);
LoggerWrapper::GetInstance()->Write(LV_STATUS, "got %x", resp);
} while (nread > 0 && resp == CM11A_INTERFACE_CQ);

I'm going to look at it when I get up.... Feel free to get a jump on this!

nosilla99

  • Veteran
  • ***
  • Posts: 120
    • View Profile
Re: CM11A - adding new lights...
« Reply #28 on: February 22, 2008, 05:49:28 pm »
Hey Guys:
Devicepoll.cpp Line 239, remove the '!'.
That fixes the polling! YAY

Tested and confirmed!

All the best,

Dan


Cheers Dan,

Given the code below and your change this would infer that in logical/boolean terms somewhere in the pluto code FALSE is defined as being true  :o

Code: [Select]
bool CSerialPort::IsReadEmpty()
{
    Sleep(0);   
    return FALSE;
}

Does anyone know where FALSE is defined as if the above is correct then it makes reading code very difficult

NOS

jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
Re: CM11A - adding new lights...
« Reply #29 on: February 22, 2008, 06:06:13 pm »
Nosilla -

I chased that for a while too, but then I noticed this:
Code: [Select]
#ifdef WIN32

so there is another IsReadEmpth() method used by linux (look further down the page)