Example of Serial Code to switch on light

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by jameswoodjaw, Apr 13, 2007.

  1. jameswoodjaw

    jameswoodjaw

    Joined:
    Jun 21, 2006
    Messages:
    2
    Likes Received:
    0
    Hi Pretty new to this and wondering if someone could lend me a hand with regards to switching on a CBus dimmer from a PC.

    I've coded the serial command in the logic engine of the piced software.

    Unfortunatly the open protocol has me confused in that on calculating the checksum I'm getting a negative number.

    The group address is 01h and on calculating the remainder I get the following:

    05h + 38h + 00h + 79h + 01h = 67h

    Basically I've got to take this away from 100h add 1, invert it and bingo theres my checksum but as you can see I'm unable to do this as it would be a negative hex no.

    I've converted it to Dec and took the last method of working out the checksum to calculate the following:

    05h + 38h + 00h + 79h + 01h + XXh = 200h

    5 + 56 + 0 + 121 + 1 + X = 512

    X = 512 - 183 = 329 which equates to 149h

    From this I've built up the procedure

    procedure on;
    begin
    OpenSerial(1, 1, 9600, 8, 1, 0, 0);
    WriteSerial(1,'$05$38$00$79$01$149$g'#13);
    end;

    But as you can guess no luck.

    The calculation in the open protocol uses a convinient 88h and if I could have changed the group hex value to that I would have but whilst my group address for the first light is 01h I'm unable to figure out the checksum.

    This is where I think I'm going wrong ?

    Any assistance would be greatly appreciated, Jim.
     
    jameswoodjaw, Apr 13, 2007
    #1
  2. jameswoodjaw

    Mr Mark

    Joined:
    Jan 27, 2006
    Messages:
    323
    Likes Received:
    5
    Location:
    FNQ
    checksum

    Hello Jim.

    A couple of things here (and anyone feel free if I'm off in the wrong direction)
    * With the serial code I've found you don't need the checksum.
    * Have you set up your com port in the initialisation section of your logic - refer to the Public Release document for more.
    * Instead of "WriteSerial(1,'$05$38$00$79$01$149$g'#13);" use WriteSerial(1,'\0538007901"#13);

    Let us know how you go,

    Mark
     
    Mr Mark, Apr 13, 2007
    #2
  3. jameswoodjaw

    Phil.H

    Joined:
    Jul 29, 2004
    Messages:
    466
    Likes Received:
    0
    Location:
    Sydney
    Based on the name of your thread "Example of Serial Code to switch on light
    " there is a real good chance you are currently embarking on a path of reinventing the good old wheel. I guess you are using PICED to test theory of serial commands directly into C-Bus via a PCI to ultimately transfer this into your own custom software platform ???? Depending on your intended platform you have a few options. C-Gate is a powerful beast for a PC/Server platform which does all the work for you and allows control and monitoring via IP sockets. There are also compiled modules for Windows and Linux allowing you to work at the API level and not worry about C-Bus protocol issues. For a real simple solution sniff packets with hyperterminal and spit them back onto the bus if you just want to turn on/off/dim.

    The question is do you really need to be dic#ing around with C-Bus protocol ??
     
    Phil.H, Apr 14, 2007
    #3
  4. jameswoodjaw

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,397
    Likes Received:
    26
    Location:
    Adelaide, South Australia
    If you are using the PAC as a proving ground, then press on.

    But if you are trying to get the PAC to control things by writing gory strings out the serial port and then into a PCI, don't bother. The PAC supports all that stuff natively. The PAC makes it very easy...

    But as Phil says, if you are using the PAC to prove something which will go onto some other processor later, then you can keep fiddling about. You may also be better off, though, just using Windows Hyperterm and hooking a PCI straight up to a COM port, then you can just type things in to prove a point or get some understanding.

    HTH
     
    ashleigh, Apr 14, 2007
    #4
  5. jameswoodjaw

    Phil.H

    Joined:
    Jul 29, 2004
    Messages:
    466
    Likes Received:
    0
    Location:
    Sydney
    See - told you I wasn't full of $hit. :D

    Let us know what you are trying to do ;)
     
    Last edited by a moderator: Apr 14, 2007
    Phil.H, Apr 14, 2007
    #5
  6. jameswoodjaw

    rhamer

    Joined:
    Aug 3, 2004
    Messages:
    673
    Likes Received:
    3
    Location:
    Melbourne, Australia
    I thought you guys didn't allow the publishing of this kind of information?

    Cheers

    Rohan
     
    rhamer, Apr 15, 2007
    #6
  7. jameswoodjaw

    Phil.H

    Joined:
    Jul 29, 2004
    Messages:
    466
    Likes Received:
    0
    Location:
    Sydney
    Hey Rohan,

    Not sure what you mean but I will take a guess that you are referring to the full C-Bus protocol. One of my biggest soapbox issues for the last five or so years has been exposing C-Bus to the big bad world. The "brothers of the brains trust" (Ashleigh, Darren, Duncan, George, Richo, Newman and a few new guys I haven't met :confused: ) have done a great job of doing just that. By today's standards there are many ways to quickly interface to C-Bus. The majority of options do not require all that tedious mucking around in hyperspace - sorry got lost there - 42 and all that sort of stuff, - The majority of options do not require mucking around with the raw C-Bus protocol. I have always said C-Bus is a small part of a big solution (commercial) it does not have to be everything and do everything but it has to be relevant to as many situations as possible.

    In a nutshell the public release protocol document, pre compiled modules, C-Gate etc plus supporting documentation are all freely available. If you wish to go deeper you have to pledge to do wierd stuff, say wierd things and learn special hand shakes - not for me. ;)
     
    Phil.H, Apr 15, 2007
    #7
  8. jameswoodjaw

    rhamer

    Joined:
    Aug 3, 2004
    Messages:
    673
    Likes Received:
    3
    Location:
    Melbourne, Australia
    Hi Phil,

    The Public Release Protocol is a very badly named subset of the full protocol that still requires the "do not tell anybody" agreement. At least not unless they to have also been taught the secret handshake.

    I know this from first hand experience as I have to continually jump through this hoop with the C-Bus driver I wrote for CQC.

    Now I am not criticising this decision at all, as a fellow software (all be it ex now) developer, I well understand the IP protection issues. and Steve and Ashleigh have been more than helpfull in finding a way to allow me to distribute my work. But I digress....

    My point was, my understanding was that when you signed up for the public release protocol, just like it's big brother full release, you weren't allowed to publish it. I would have thought listing it here violated that agreement.

    Anyway, I'm certinly not out to dob anybody in, I was just looking for a clarification.

    Cheers

    Rohan
     
    rhamer, Apr 15, 2007
    #8
  9. jameswoodjaw

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,397
    Likes Received:
    26
    Location:
    Adelaide, South Australia
    You are correct, it should not really be listed here :(

    Now that it is we might as well make the best of it and set folks in the right direction.

    Like many things, we move carefully and slowly. The public release has been a success of sorts. Perhaps one day there will be a change of heart that makes it fully and truly public. It's a big perhaps, we have to see how the current arrangements continue to work out.
     
    ashleigh, Apr 15, 2007
    #9
  10. jameswoodjaw

    Phil.H

    Joined:
    Jul 29, 2004
    Messages:
    466
    Likes Received:
    0
    Location:
    Sydney
    Who said anything about placing the Public Release Document here in the forum. My understanding is you can register for it on the CIS website and it will be emailed to you in minutes. I had to recover my PC recently and it was quicker to get the document from CIS than it was to dig around my CD backups
     
    Phil.H, Apr 16, 2007
    #10
  11. jameswoodjaw

    Phil.H

    Joined:
    Jul 29, 2004
    Messages:
    466
    Likes Received:
    0
    Location:
    Sydney
    Just to check that I was not going mad I have registered Santa Claus to reveive the public protocol document http://www2.clipsal.com/cis/technical/downloads/cbusprotocol_personal
    I suppose I better call him later and explain what the email from CIS is all about ;)

    Rohan, I understand your frustration re jumping through hoops. Had to do a bit of hoop jumping myself recently on this point. I do think the poking and proding is worth the effort in the long run. Having certain email addresses helps ;)
     
    Phil.H, Apr 16, 2007
    #11
  12. jameswoodjaw

    rhamer

    Joined:
    Aug 3, 2004
    Messages:
    673
    Likes Received:
    3
    Location:
    Melbourne, Australia
    It's really not that much of a problem, especially if you were to only use it yourself (which is really the point of the release)

    I just have to muck around a bit to allow my work to be distributed, because it is viewable as source and therefore could be reverse engineered.

    But, not for much longer, so it will soon cease to be an issue at all.

    Cheers

    Rohan
     
    rhamer, Apr 16, 2007
    #12
  13. jameswoodjaw

    raiya_23

    Joined:
    Jun 22, 2009
    Messages:
    16
    Likes Received:
    0
    Location:
    Pakistan
    I have read the public release documents I havent found anything regarding setting up the com port in the initialisation section of my logic

    How do I do that?

    Thanks
     
    raiya_23, Nov 17, 2009
    #13
  14. jameswoodjaw

    Newman

    Joined:
    Aug 3, 2004
    Messages:
    2,203
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    If you have installed C-Bus Toolkit, connected the USB PC Interface to C-Bus and connected the USB PC interface to your PC then the PC Interface will be available as a virtual com port, which you talk to just like talking to a serial PC Interface. No other initialisation is required.
     
    Newman, Nov 17, 2009
    #14
  15. jameswoodjaw

    raiya_23

    Joined:
    Jun 22, 2009
    Messages:
    16
    Likes Received:
    0
    Location:
    Pakistan
    Oh yes I have done that...now I should type the commands in C gate?
     
    raiya_23, Nov 19, 2009
    #15
  16. jameswoodjaw

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    It would help if you could tell us what you are trying to do.
     
    Darren, Nov 19, 2009
    #16
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.