RS232 replies from CBus

Discussion in 'C-Bus Serial Protocols' started by UK Household Automation, Aug 26, 2010.

  1. UK Household Automation

    UK Household Automation

    Joined:
    Aug 6, 2004
    Messages:
    103
    Likes Received:
    0
    Can anyone point me to the correct thread please? I've been scanning through the forums but I haven't quite seen the right one.

    I'm issuing commands such as
    \05380002030000g<CR>
    and
    \0538000203FF00g<CR>

    from a program called Hercules runing on my PC to a 5500PC (RS232 PC Interface)

    The first time a command is sent after connecting the PCI (to the CBus net)
    I get the following reply (assuming I've sent \05380002030000g<CR>)
    \05380002030000gg.
    (i.e. a clearly understandable reply or echo of the the command sent.)

    But any subsequent command will return only the acknowledgment letter
    (g.)
    when what I really want is the longer reply as described above. Have I neglected to set up the PCI in some way?

    I've looked at the documents on the CBus enabled site but I think I need to gain more knowledge before I can understand them fully.

    Help!..............anyone?
     
    UK Household Automation, Aug 26, 2010
    #1
  2. UK Household Automation

    Newman

    Joined:
    Aug 3, 2004
    Messages:
    2,203
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    The lower case 'g' letter on the end of the string is putting the PCI into 'smart' mode, where it no longer echoes sent messages back up the serial port.

    BTW, your messages seem to contain an extra $00 byte on the end, which serves no purpose.
     
    Newman, Aug 26, 2010
    #2
  3. UK Household Automation

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,391
    Likes Received:
    24
    Location:
    Adelaide, South Australia
    What you saw was the echo. The PCI echos back what is sent to it, unless its in Smart mode, in which case it does not.

    A side effect of issuing the lower case letter is the it flips to smart mode - after receiving, echoing, and then processing that character.

    You really need to download and read the documentation on how to drive the PC interface, this will help ensure that you initialise it correctly when you start sending stuff to it (the first thing you should be doing is to set the mode).
     
    ashleigh, Aug 27, 2010
    #3
  4. UK Household Automation

    UK Household Automation

    Joined:
    Aug 6, 2004
    Messages:
    103
    Likes Received:
    0
    Thank you both for your words of wisdom.

    I've just got back in the orifice to continue fiddling with this and I can see the string that I expected coming back now.
    Am I right in thinking that this reply means that the PCI is saying:

    "This is the action that I'm taking"

    and not

    "This is what you've told me to do- but whether I do it or not is another matter"

    (Forgive my school-boy language.)
     
    UK Household Automation, Aug 31, 2010
    #4
  5. UK Household Automation

    Newman

    Joined:
    Aug 3, 2004
    Messages:
    2,203
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    The echo of the serial string is purely that, an echo. It is just telling you what data the PCI has received.

    When using acknowledgement characters, the "g." is telling you that the unit successfully transmitted your message on to C-Bus. If you get anything other than a full stop character after the lower case letter, it tells you that the transmission on to C-Bus was unsuccessful.
     
    Newman, Aug 31, 2010
    #5
  6. UK Household Automation

    UK Household Automation

    Joined:
    Aug 6, 2004
    Messages:
    103
    Likes Received:
    0
    OK,

    Unfortunately that's not the answer i was hoping for but at least i know where I stand now.

    I was hoping to lift the GA and Level (00-FF) to get feedback through regular expression. Do you think this is possible at all?

    Cheers, JP
     
    UK Household Automation, Sep 1, 2010
    #6
  7. UK Household Automation

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,391
    Likes Received:
    24
    Location:
    Adelaide, South Australia
    No.

    You are asking for a monitor of the bus.

    You can do this but not the way you thought. Not on sending commands TO the PCI.

    You need to do 2 things:

    1. When you send a command to the PCI, look for the "." coming back, this means the command you sent WAS transmitted into the bus and the nature of the beast means that if it was sent in by the PCI then IT WAS RECEIVED BY ALL NODES and therefore that command defines the state of what you set. (ie ... all good and you view of the state is the same as the rest of the network). If you don't get back the "." then the transmit failed and there are lumps in the custard.

    2. You need to set the PCI to monitor the bus traffic. The form of what comes OUT of the PCI is not the same as what you send in, but it is similar. (Read the doco.) You can easily confuse the echo with a monitor, thats why setting the PCI mode is so important. Then you can decode the monitor messages that come out of the PCI, and from that you can update your state to that of the other devices.

    If this all seems too hard, then poke around on soureforge for "cbus module" and download that. Use it. Its written in portable C, and you may need to tweak a settings file to suit your target system. It does all the parsing for you and provides you with a C API interface. Use it, and life is sweet. Don't use, and you have to do it all yourself. Possible, but you have a world of reinvention pain in front of you :) :)
     
    ashleigh, Sep 1, 2010
    #7
  8. UK Household Automation

    UK Household Automation

    Joined:
    Aug 6, 2004
    Messages:
    103
    Likes Received:
    0
    -"CLICK"!

    Finally I think I've learned something!

    Thanks fellas for your guidance, I now have a better understanding of how the initialisation strings work and I think I'm getting something back that I can work with now.

    Cheers
    JP
     
    UK Household Automation, Sep 28, 2010
    #8
  9. UK Household Automation

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,391
    Likes Received:
    24
    Location:
    Adelaide, South Australia
    :) Excellent. The initialisation is REALLY REALLY important!
     
    ashleigh, Sep 29, 2010
    #9
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.