Home AMX User Forum NetLinx Studio

Lutron RS-232 parsing

Looking for some help & guidance on parsing data coming from a Lutron HWI system.
The designer of the project is having source selection buttons placed on the Lutron keypads.
So i need to monitor all button presses of the Lutron system to watch for specific keypad button presses.

example keypad.

b1: am/fm press(select source) press after selected(preset up) hold after selected(scan up)
b2: cd press(select source) press after selected(track up) hold after selected (next disk)
b3: digital press(select source)
b4: ipod press(select source & play) press after selected (next track) hold after selected (play/pause)
b5: none
b6: off press (local system off) hold (house off)

b23[dn]: vol dn
b24[up]: vol up

trying to figure out how to store incoming info and make actions based on presses

Little above my head for only going through programmer 1

Any help would be a blessing!!!

Thanks All,
Ian

Comments

  • ericmedleyericmedley Posts: 4,177
    I'd read up on the DATA_EVENT

    also, the AMX Lutron Homeworks module is a pretty bullet-proof module and works quite well. I'd download it and follow its instructions.

    We've done a few installations using Lutron as a keypad for 'other' things. Now our company policy on this is: Use Lutron for something other than lights, we break a finger. One per infraction...
  • Just on my way out, but real quickly... you can monitor the LED state on the keypad pretty easily to determine state changes on buttons, or you could have the Lutron programmer set up drivers/strings that get sent out when a button is pressed. You would then parse the string sent out by the Homeworks processor and do what you need to do.

    --John
  • ibryantibryant Posts: 13
    I know I know...i have faught this thing from the begining...Nothing i can do.
    what module where you using? Homeworks, Homeworks Interactive or Homeworks P5?
  • ericmedleyericmedley Posts: 4,177
    ibryant wrote: »
    I know I know...i have faught this thing from the begining...Nothing i can do.
    what module where you using? Homeworks, Homeworks Interactive or Homeworks P5?

    LutronHWI_v2[1].1_032305

    Homeworks. It depends upon which Lutron processor you're installing.
  • ibryantibryant Posts: 13
    ericmedley wrote: »
    LutronHWI_v2[1].1_032305

    there isnt a v2[1].1
    there is a 2.2 and a 2.3
  • ericmedleyericmedley Posts: 4,177
    Oh another thing...

    I would have the Lutron programmer create virtual keypads for all your AMX stuff. That way, if the Lutron program changes (ha! whadda mean IF???) it won't break your program.

    We have a few pretty hard-n-fast rules.

    AMX does no heavy lifting for Lurton.
    All AMX ougoing interaction happens on a virtual keypad.
    I only take feedback from keypads I'm using.
  • I recently created a program for a lutron lighting controller, and it looks like the strings are similar. It looks like you may have to chage the strings from 'a1' to 'b1' etc. but this should work.

    The way I did it is by setting up a buffer in the start section which watches incomming strings. As strings come in I tend to put them into a second variable(character array) and clear the buffer right away.

    Then you make a comparison in the data event for that device. ie, whenever a string comes in it decides if it is recognised (using the find_string function) and updates buttons, etc.

    Once you have the buffer created, you can watch those variables in realtime by starting debug mode in Studio.

    Good luck!

    DEFINE_VARIABLE

    CHAR LIGHTING_BUFFER[100] //BUFFER TO STORE INCOMING MESSAGES
    CHAR LIGHTING_FEEDBACK[100] //BUFFER TO STORE INCOMING MESSAGES

    DEFINE_START

    CREATE_BUFFER dvLIGHTING,LIGHTING_BUFFER //STARTS THE BUFFER

    DEFINE_EVENT

    DATA_EVENT [dvLIGHTING]
    {
    ONLINE:
    {
    SEND_COMMAND dvLIGHTING,'HSOFF'
    SEND_COMMAND dvLIGHTING,"'SET BAUD 9600,N,8,1'"
    }
    STRING:
    {
    LIGHTING_FEEDBACK = LIGHTING_BUFFER
    CLEAR_BUFFER LIGHTING_BUFFER
    IF (FIND_STRING("':a01',$0D")) LIGHTINGPRESET_FB = 1
    IF (FIND_STRING("':a11',$0D")) LIGHTINGPRESET_FB = 2
    IF (FIND_STRING("':a21',$0D")) LIGHTINGPRESET_FB = 3
    IF (FIND_STRING("':a31',$0D")) LIGHTINGPRESET_FB = 4
    IF (FIND_STRING("':a41',$0D")) LIGHTINGPRESET_FB = 5
    IF (FIND_STRING("':a51',$0D")) LIGHTINGPRESET_FB = 6
    IF (FIND_STRING("':a61',$0D")) LIGHTINGPRESET_FB = 7
    IF (FIND_STRING("':a71',$0D")) LIGHTINGPRESET_FB = 8
    IF (FIND_STRING("':a81',$0D")) LIGHTINGPRESET_FB = 9
    IF (FIND_STRING("':a91',$0D")) LIGHTINGPRESET_FB = 10
    }
    }
  • mschardt wrote: »
    I recently created a program for a lutron lighting controller, and it looks like the strings are similar. It looks like you may have to chage the strings from 'a1' to 'b1' etc. but this should work.

    The way I did it is by setting up a buffer in the start section which watches incomming strings. As strings come in I tend to put them into a second variable(character array) and clear the buffer right away.

    Then you make a comparison in the data event for that device. ie, whenever a string comes in it decides if it is recognised (using the find_string function) and updates buttons, etc.

    Once you have the buffer created, you can watch those variables in realtime by starting debug mode in Studio.

    Good luck!

    DEFINE_VARIABLE

    CHAR LIGHTING_BUFFER[100] //BUFFER TO STORE INCOMING MESSAGES
    CHAR LIGHTING_FEEDBACK[100] //BUFFER TO STORE INCOMING MESSAGES

    DEFINE_START

    CREATE_BUFFER dvLIGHTING,LIGHTING_BUFFER //STARTS THE BUFFER

    DEFINE_EVENT

    DATA_EVENT [dvLIGHTING]
    {
    ONLINE:
    {
    SEND_COMMAND dvLIGHTING,'HSOFF'
    SEND_COMMAND dvLIGHTING,"'SET BAUD 9600,N,8,1'"
    }
    STRING:
    {
    LIGHTING_FEEDBACK = LIGHTING_BUFFER
    CLEAR_BUFFER LIGHTING_BUFFER
    IF (FIND_STRING("':a01',$0D")) LIGHTINGPRESET_FB = 1
    IF (FIND_STRING("':a11',$0D")) LIGHTINGPRESET_FB = 2
    IF (FIND_STRING("':a21',$0D")) LIGHTINGPRESET_FB = 3
    IF (FIND_STRING("':a31',$0D")) LIGHTINGPRESET_FB = 4
    IF (FIND_STRING("':a41',$0D")) LIGHTINGPRESET_FB = 5
    IF (FIND_STRING("':a51',$0D")) LIGHTINGPRESET_FB = 6
    IF (FIND_STRING("':a61',$0D")) LIGHTINGPRESET_FB = 7
    IF (FIND_STRING("':a71',$0D")) LIGHTINGPRESET_FB = 8
    IF (FIND_STRING("':a81',$0D")) LIGHTINGPRESET_FB = 9
    IF (FIND_STRING("':a91',$0D")) LIGHTINGPRESET_FB = 10
    }
    }

    Although this may work, the issue you might run into is when multiple strings end up in the buffer. If LIGHTING_FEEDBACK = :a01,$0D,:a51,$0D then your variable gets set to 1 and the other command is essentially ignored.

    The string parsing method should go through the data one string at a time regardless of how the strings come in. Here is an example:
    DATA_EVENT [dvLIGHTING]
    {
        ONLINE:
        {
    	SEND_COMMAND dvLIGHTING,'HSOFF'
    	SEND_COMMAND dvLIGHTING,"'SET BAUD 9600,N,8,1'"
        }
        STRING:
        {
    	STACK_VAR CHAR nMyString[50]
            WHILE(FIND_STRING(LIGHTING_BUFFER,"$0D",1)
            {
                  nMyString = REMOVE_STRING(LIGHTING_BUFFER,"$0D",1)
                  
                  // Do something with nMyString, that is your feedback
            }
        }                                 
    }
    

    Furthermore, what I usually do with the incoming string is send it to a function for parsing, but that parsing can happen in the string event as well.
Sign In or Register to comment.