Sample Code to get us going

Discussion in 'C-Bus Serial Protocols' started by theboyg, May 2, 2009.

  1. theboyg

    theboyg

    Joined:
    Apr 3, 2005
    Messages:
    206
    Likes Received:
    8
    How about a sample piece of code to get us going - a real world example we can then map to 'translate' the docs :)

    How's this : Send the word 'Hello' to Group 20

    Cheers
     
    theboyg, May 2, 2009
    #1
    1. Advertisements

  2. theboyg

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    The format of the labelling command is:

    <Header> <Group Address> <Options> <Language> <Bytes>

    <Header> = %101LLLLL = $A8 (LLLLL = 5 + 3 = 8)

    <Group Address> = 20 = $14

    <Options> = $00 (Lighting, Text, Flavour 0)

    <Language> = $01 (English)

    <Bytes> = 48656C6C6F ("Hello")

    So the whole string is: \053800A814000148656C6C6F<CR>
     
    Darren, May 2, 2009
    #2
    1. Advertisements

  3. theboyg

    theboyg

    Joined:
    Apr 3, 2005
    Messages:
    206
    Likes Received:
    8
    Perfect - thanks !
     
    theboyg, May 2, 2009
    #3
  4. theboyg

    dave240t

    Joined:
    Apr 10, 2008
    Messages:
    26
    Likes Received:
    0
    i still need help

    I understand the group address and language i assume the flavour is like the variant as for the bytes from hello how is this converted to bytes and i don't understand how to use the header can you please help as this would help me alot
     
    dave240t, Jun 16, 2009
    #4
  5. theboyg

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,419
    Likes Received:
    60
    Location:
    Adelaide
    This is all explained in the documentation...

    The header is the command, 3 bits of which define it as a label command, the remaining 5 define the length (number of data bytes following).

    The data for the label text is just the ascii codes for the letters..

    $48 = "H"
    $65 = "e"
    etc... Google "ascii codes" for more info.

    Nick
     
    NickD, Jun 17, 2009
    #5
    1. Advertisements

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.