Home AMX User Forum NetLinx Studio

Need to send a string to a device at regular intervals

I need to poll a projector for lamp status on a regular basis, but nothing I try seems to work.

I tried a WAIT in the runtime loop, and nothing happens.

I tried the following code in the runtime, and nothing happens:

IF (TIME='??:??:?0') // Execute every 10 seconds
{
WAIT 11
SEND_STRING dvVideoProjectorIP,"'TLPS 1',13"
}

Comments

  • HedbergHedberg Posts: 671
    Most people will probably tell you that the preferred thing to do is to use a timeline.

    However, you can do it in define program, there's nothing wrong with that if that's what you want.

    Looks like you are trying to send the string every 11.1 seconds. Try this:
    WAIT 111
      SEND_STRING dvVideoProjectorIP,"'TLPS 1',13"
    

    This will not start a new wait each time define_program runs, even though it might look like it will. Waits will not "stack" when encountered repeatedly in define_program or in functions, subroutines, or events.

    Now, as for your
    IF (TIME='??:??:?0')
    

    this: '??:??:?0', is a string literal. You are not using wild card characters, you are using question mark characters. I don't believe wild cards work within Netlinx programming. Look in the Netlinx documentation for various string parsing functions such as LEFT_STRING, RIGHT_STRING, MID_STRING to see how to extract a character from a particular expression.
  • Spire_JeffSpire_Jeff Posts: 1,917
    Hedberg wrote: »
    \
    this: '??:??:?0', is a string literal. You are not using wild card characters, you are using question mark characters. I don't believe wild cards work within Netlinx programming. Look in the Netlinx documentation for various string parsing functions such as LEFT_STRING, RIGHT_STRING, MID_STRING to see how to extract a character from a particular expression.

    Check out COMPARE_STRING(). I'm not sure of the overhead involved, but it does allow wildcard searching, but not the multicharacter wildcard (*).

    Jeff
  • HedbergHedberg Posts: 671
    Spire_Jeff wrote: »
    Check out COMPARE_STRING(). I'm not sure of the overhead involved, but it does allow wildcard searching, but not the multicharacter wildcard (*).

    Jeff

    Ok, that's one I've not used.
    Instead of
    IF (TIME='??:??:?0')
    
    we should have
    IF (COMPARE_STRING(TIME,'??:??:?0'))
    
    Or, could use RIGHT_STRING (or other functions)about as easily.
  • Joe HebertJoe Hebert Posts: 2,159
    Or you can use the built-in functions like:

    TIME_TO_SECOND(TIME)

    instead of the string parsing.
  • If you just want to send a string to a device at regular intervals just do this:

    Define_Program

    wait 10
    {
    //poll the device
    }
  • PhreaKPhreaK Posts: 966
    I think you may have to name the wait for it to work.
  • Joe HebertJoe Hebert Posts: 2,159
    PhreaK wrote: »
    I think you may have to name the wait for it to work.
    It will work the same with or without the name.
    By naming the wait you can manipulate it but it still works the same.
  • PhreaKPhreaK Posts: 966
    Joe Hebert wrote: »
    It will work the same with or without the name.
    By naming the wait you can manipulate it but it still works the same.

    My bad.

    This post is at least 10 characters.
  • dmenkedmenke Posts: 25
    Thanks for all the ideas and help. I'm not sure how, but the WAIT I put in the runtime loop started to run. It's all good now.

    Doug
Sign In or Register to comment.