Home AMX User Forum NetLinx Studio

Converge Response Function

This is my first job dealing with Clearone devices via IP. In the past, I had always controlled Clearone devices serially and I have never had any problems. The problem I am having with IP is that I have to enter a username and password. In the DATA_EVENT for the Converge, I have this:
STRING:
            {
                 IF(FIND_STRING(cConverge_Buff,'user:',1))
                 {
                       SEND_STRING dvConverge,"'clearone',13"
                 }
                 WHILE(FIND_STRING(cConverge_Buff,"13,10",1))
                 {
                      fnConverge_Response()
                 }
             }

I don't like the FIND_STRING 'user' part. The WHILE loop is what I have always used and never had issues. So, I just modified it a little for the user and password info. Here is the section of my function handling the password portion:
DEFINE_FUNCTION fnConverge_Response()
{
      LOCAL_VAR CHAR cMSG[50]
      cMSG = REMOVE_STRING(cConverge_Buff,"13,10",1)
      IF(LENGTH_STRING(cMSG) != 0)
      {
          SET_LENGTH_STRING(cMSG,LENGTH_STRING(cMSG) - 2)
          SELECT
          {
              ACTIVE(FIND_STRING(cMSG,'pass:',1)):
              {
                   SEND_STRING dvConverge,"'converge',13"
              }
              ACTIVE(FIND_STRING(cMSG, "cConverge_ADDRESS, 'other stuff'",1)):
             {
                  do other things like adjust bargraph values or toggle MUTE icons
             }
          }
      }
}
This was the only way I could get the Master to correctly login to the Converge. I tried moving everything into the function, but when I did that, I could never get past the user name request. I am guessing the big clue to my problem is "13,10." My function is set to run every time the buffer has a CR and a LF. When the Converge asks for a username, there is no CR and LF to trigger the function. When I send the string 'clearone' as the user name, then the CR and LF happens which causes the function to run which then handles the password request. It works as is, but it just doesn't seem like this is the best way to operate. Is there a better way to do this?

Comments

  • Spire_JeffSpire_Jeff Posts: 1,917
    I don't think there is anything wrong with the approach you are taking. You could add an else to the end of the if statement since there should not be anything to parse until you are logged in (right?). Sure, you are running two find_strings every time a string is received, but I can't see a better way to do it at the moment.

    Jeff
  • That is pretty much the exact solution I came up with when I added IP connectivity to my ConvergePro module.
    if(nComType == nComIP)
    	{
    	    select
    	    {
    		active(find_string(data.text,'user:',1)):
    		{
    		    send_string dvConvergePro, "sUserName,$0D"
    		}
    		active(find_string(data.text,'pass:',1)):
    		{
    		    send_string dvConvergePro, "sPassword,$0D"
    		}
    		active(find_string(data.text,'Level:',1)):
    		{
    		    flagIPReady = true
    		}
    	    }
    	}
    	while(find_string(sBuffer,"$0A",1))
    	{
                    //process feedback here
    

    Yours is actually a bit cleaner and probably less wasteful than mine. I also can't see a better way to do it than what you've come up with.
  • What do you guys think about using mainline to call the Converge function? That would eliminate the need to have a WHILE loop in the DATA_EVENT for the Converge. Something like:
    DEFINE_PROGRAM
    
    IF(LENGTH_STRING(cConverge_Buffer))
           fnConverge_Response()        
    

    I don't have a Converge in front of me to play with, but I have an idea in my head how that would work. As always, what's inside my head doesn't necessarily work in real life. Thoughts?
Sign In or Register to comment.