Home AMX User Forum AMX General Discussion
Options

TCP/IP Feedback

Im using a NI-2100 link to audia flex biamp via tcp/ip.
is there a way that the NI can detect if the AUDIA is on or off
and if it is on 'do this parameter'
if off 'do this parameter'

Comments

  • Options
    ericmedleyericmedley Posts: 4,177
    arvinnino wrote: »
    Im using a NI-2100 link to audia flex biamp via tcp/ip.
    is there a way that the NI can detect if the AUDIA is on or off
    and if it is on 'do this parameter'
    if off 'do this parameter'

    If you're using an AMX module (I don't know if there even is one..) they quite often have a feedback channel assigned to let the programmer know whether or not the master is indeed in contact with the device.

    If you're making your own, you'll need to come up with some scheme to determine whether or not you talking to the box. For example, if you're polling the device for status, you could set a status flag and/or turn a channell on or off on a virtual device. Then once you see a change in the flag and/or channel you can do something. A lot depends upon how the device communicates back to you and what it will tolerate regarding polling. Soome devices do not like to be poked on all the time. Other's don't care.
  • Options
    Im using IP_CLIENT_OPEN command to connect to audia
    my problem is if the Netlinx booted first it will send this command automatically to audia regardless whether the audia is on or off. in this case the command was sent before the audia finish booting so the tcp/ip port will not open.
  • Options
    HedbergHedberg Posts: 671
    arvinnino wrote: »
    Im using IP_CLIENT_OPEN command to connect to audia
    my problem is if the Netlinx booted first it will send this command automatically to audia regardless whether the audia is on or off. in this case the command was sent before the audia finish booting so the tcp/ip port will not open.

    If IP_CLIENT_OPEN fails to connect to the server, it will give an error, won't it? Perhaps you can use the error code to do what you want.
  • Options
    Hedberg wrote: »
    If IP_CLIENT_OPEN fails to connect to the server, it will give an error, won't it? Perhaps you can use the error code to do what you want.

    yes i think it can be done.. the problem is i dont know how... =)
  • Options
    AuserAuser Posts: 506
    arvinnino wrote: »
    yes i think it can be done.. the problem is i dont know how... =)

    A quick search of the forums yields the following, which has some useful tips: http://www.amxforums.com/showthread.php?7151-Age-ol-IP-Question.

    The AMX Technote linked to in that thread has a code sample attached which should provide most of what you need to know.

    A couple of important points to help you on your way:

    - Calling IP_CLIENT_OPEN alone will not open a reliable connection to the device. There's nothing to ensure that the connection will be successful first time around (as you've found) or that the socket will subsequently stay open.

    - In order to create a reliable connection to the remote device you need to trap the offline and error events thrown by the NetLinx IP device (see the code sample referred to above). When such an event is thrown you should call IP_CLIENT_OPEN again to attempt to reestablish the connection. You may find that you need to wait for a period of time after such an event before you try opening the socket again.
  • Options
    another question

    i have another question. i have a biamp Audia flex as DSP and it is being controlled by 6 pcs MET 6N keypad via TCP/IP, my controller is NI-2100. in able me to connect the two processors i used online event of keypads, every time the NI-2100 detect that a keypad is online it will send a command to open port and send strings.

    My problem is everytime i open the devices since i have 6pcs keypad the command is being sent 6 times and if biamp turn off and turn back on the connection will lost and will never connect not unless i restart NI-2100. is theres a way to check the status of connection and send a command depending on the status of connection?



    DEFINE_VARIABLE
    VOLATILE DEV dvMETKP_Audia1[6] =
    {
    dvMET1, dvMET2, dvMET3, dvMET4, dvMET5, dvMET6
    }

    DEFINE_EVENT
    DATA_EVENT[dvMETKP_Audia1]
    {
    ONLINE:
    {
    IP_CLIENT_OPEN (dvBiamp.port, BiampIP, 23, 1)
    SEND_COMMAND dvMETKP_Audia1,"'@BRT-32,0'"
    SEND_COMMAND dvMETKP_Audia1,"'@WBRT-32,25'"
    ON[dvMETKP_Audia1,3]
    ON[dvMETKP_Audia1,4]
    SEND_STRING dvBiamp,"'RECALL 0 PRESET 1001',$0D,$0A"
    }
    }
  • Options
    viningvining Posts: 4,368
    I think you need to change the entire approach.

    Is the Biamp a maintained connection (always connected) at least in theory?

    If so connect in define start and create another data event for the biamp. Read the link posted ealier about setting connection flags, etc. Then in define program re-connect if your dropped unless you have a timeline that runs that could be used for that purpose.

    In the data event handler for the biamp send the string when it's online not when the keypads come online. Sending a string to a device you just sent the command to open a socket with most likely won't work since an IP connection often take several seconds or more.

    If you want to trigger the biamp to come online when the KPs come online that might make sense but I don't see it from where I'm sitting, but maybe. If you do, again go back to the link mentioned and set flags so that which ever KP comes online first opens the port, set a flag to "pending" to prevent further KPs from attempting the same when they come online. Otherwise you'll generate alot of errors and bug out the master in the process.

    create constants similar to this:
    IP_Disable = 0 IP_Disco = 1, IP_Pending = 2, IP_Connected = 3

    then in you online event for the KPs if that's really what you want to do
    ONLINE:
         {
         STACK_VAR INTEGER nIndx ;
         
         nIndx = GET_LAST(dvMETKP_Audia1) ;
         if(nIPconnection == IP_Disco)
    	  {
    	  nIPconnection = IP_Pending ;
    	  IP_CLIENT_OPEN (dvBiamp.port, BiampIP, 23, 1)
    	  }
         SEND_COMMAND dvMETKP_Audia1[nIndx],"'@BRT-32,0'"
         SEND_COMMAND dvMETKP_Audia1[nIndx],"'@WBRT-32,25'"
         ON[dvMETKP_Audia1[nIndx],3]
         ON[dvMETKP_Audia1[nIndx],4]
         }
    
    also use the get_last function and just send your commands to the KP that actually comes online. otherwise you sending to devices over and over again and likely to devices that haven't yet come online so send only to the fellow that triggers the event.
  • Options
    Here is my typical approach to IP connections
    define_device
    dvAudia = 0:3:0
    
    define_variable
    
    integer nAudiaConnected = 0
    
    define_event
    data_event[dvAudia]
    {
         online:
         {
              nAudiaConnected = 1
         }
         offline:
         {
              nAudiaConnected = 0
    
              ip_client_open(dvAudia.port,cAudiaIP,23,IP_TCP)
         }
         string:
         {
               fnParseBuffer(sAudiaBuffer)
         }
    }
    

    You can then send communications based on the flag that is set. You can also add code to time it out and throw another flag if the port fails to open for some reason. Something else I did recently was to Telnet into the master through code once it came online and ping the IP address of the device I wanted to see. I have that code in an include file if anyone is interested in it.
  • Options
    jimmywjimmyw Posts: 112
    Here is my typical approach to IP connections
    Something else I did recently was to Telnet into the master through code once it came online and ping the IP address of the device I wanted to see. I have that code in an include file if anyone is interested in it.

    Please do, I like to add to my bag of tricks, could think of a few things that would come in handy with but never got around to it myself, too busy with too short of deadlines.

    Jimmy
  • Options
    HedbergHedberg Posts: 671
    to "telnet" into the master itself, create a client and connect to 127.0.0.1, the "local host". Then, you can send any telnet command to the master that the master will respond to -- including ping.
  • Options
    Hedberg wrote: »
    to "telnet" into the master itself, create a client and connect to 127.0.0.1, the "local host". Then, you can send any telnet command to the master that the master will respond to -- including ping.

    I hadn't thought of that one. I just opened a connection to the IP of the the master on port 23 and sent it the ping request via a timeline. The code is attached to this message.

  • Options
    HedbergHedberg Posts: 671
    I hadn't thought of that one. I just opened a connection to the IP of the the master on port 23 and sent it the ping request via a timeline. The code is attached to this message.

    And I didn't know you could do that. I always thought that you couldn't do a telnet connection from an IP address to itself and that's what the local host was for. I really don't know enough about TCP/IP protocol to understand this stuff that well.
  • Options
    Hedberg wrote: »
    And I didn't know you could do that. I always thought that you couldn't do a telnet connection from an IP address to itself and that's what the local host was for. I really don't know enough about TCP/IP protocol to understand this stuff that well.

    I was expecting it not to work, but it did just fine. Kind of surprised me when it actually did work.
  • Options
    viningvining Posts: 4,368
    I was expecting it not to work, but it did just fine. Kind of surprised me when it actually did work.
    In the module I posted in modpedia I also used the IP but used 127.0.0.1 as the default to use if an IP was specified. Not really sure what my thinking was unless I left the door open in case you wanted to telnet something other than the master. In code that uses this file I always supply the IP so localhost never gets used. Don't know if I wondered why at the time or not. I guess it is what it is and us mortal men can only wonder why.
Sign In or Register to comment.