Home AMX User Forum NetLinx Studio

AMX MAX v3 TCP Control Passthru

I'm working on receiving data from an older MAX unit by bypassing the module and using the commands in the protocol reference guide. It's simple enough to use the module with the passthru command; however, it would seem the correct approach when a response from the MAX is required would be to open a tcp port with the MAX and proceed accordingly. Does anyone have any experience with this? To be specific, my first question is, which tcp port does the MAX command protocol listen to?

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    billyung wrote:
    To be specific, my first question is, which tcp port does the MAX command protocol listen to?
    I'm not sure what flavor of MAX you are referring to but the MAX MMS-125 uses port 8000. I opted to bypass the module entirely (I don't think you can do that will the newer models.) One thing to note is that you can't keep a connection open with the MAX. It can only handle one connection at a time and the MAX will drop the line after processing a command. So if you want to monitor feedback you'll have to use a TIMELINE to re-open a connection and issue the dvd status command.

    HTH
  • DHawthorneDHawthorne Posts: 4,584
    Because, as Joe mentioned, the MAX drops the connection with each command, I would advise using the passthru command so that the comm module handles your connections. If that's not feasible, it might be better to scrap even the comm module and start from scratch, because you will be having all manner of collisions as both modules try to make connections. Then you'll have the cutomer pounding a button to make something happen because the modules are wrestling each other for the connection, and all of it will happen at once when it finally gets through.
  • billyungbillyung Posts: 16
    Thanks to both of you for your prompt and incisive answers. I did find it was port 8000 through a portscan. I did a little experimenting (it is an MMS-125) with a tiny web (php type) program and I'm not seeing the connection drop that you're talking about. Maybe I'm not understanding exactly what you're saying. What I'm doing is opening a connection, sending a command, receiving a response and then closing the connection. Seems to work okay in web world. Not sure how Netlinx might be different.

    My intention was to build an enhanced touchpanel interface for the older MAX. I wonder if anyone would be interested in a full featured web interface for the older MAX boxes...

    I'd love to hear about the interface that you've created too.
  • Joe HebertJoe Hebert Posts: 2,159
    DHawthorne wrote:
    it might be better to scrap even the comm module and start from scratch

    That's the route I chose to take. I might not have been clear about that in my last post.
  • billyungbillyung Posts: 16
    Joe,
    Can you share some sample code from your direct Netlinx communication with the MMS-125? Specifically, I would like to use the DVD Details command to pull over the genre and keywords from the MAX database for display on a touchpanel.

    Thanks,


    Bill
  • billyungbillyung Posts: 16
    I'm really stuck. Can't get a connection to open at all. I've read every post there is and can't figure it out. I consistently get a (connection refused) error. Here's my code. Any help would be appreciated. The MAX works so simply over IP using other languages. I can't understand why I'm finding Netlinx so quirky.


    BUTTON_EVENT[dvTP01_4, 112] // Get DVD Details
    {
    PUSH :
    {
    (* Open The Client *)

    IP_CLIENT_OPEN(dvIPClient.Port,'192.168.254.30','8000',1)
    wait_until(maxiponline) //set to 1 in online max ip event, 0 in offline event
    {
    SEND_STRING 0,"'Opening tcp port for Max'"
    SEND_STRING dvIPClient.PORT, "'DVD Details 1|',SelectedDVDID,'\n'"
    SEND_STRING 0,"'Getting DVD Details for DVD #', SelectedDVDID"
    }
    SEND_COMMAND dvTP01_4,"'PPON-','MMS Details'"

    }
    }


    (* MAX IP Data Handler *)

    DATA_EVENT[dvIPClient]
    {
    ONERROR:
    {
    SEND_STRING 0,"'Device ',DEV_TO_STRING(DATA.Device),':',GET_IP_ERROR(DATA.Number),13,10"
    }

    ONLINE:
    {
    maxiponline=1
    }

    OFFLINE:
    {
    maxiponline=0
    SEND_STRING 0,"'MAX IP Connection dropped.'"
    }

    STRING:
    {
    send_command dvTP01_4, "'TEXT97-', Data.Text"
    SEND_STRING 0,"'string: client=',Data.Text"
    IP_CLIENT_CLOSE (dvIPClient.port)
    }

    }
    ________
    buy extreme vaporizer
  • Joe HebertJoe Hebert Posts: 2,159
    billyung wrote:
    Specifically, I would like to use the DVD Details command to pull over the genre and keywords from he MAX database for display on a touchpanel.
    Sorry can?t help you there. My situation didn?t require the need for genre and keywords.
    billyung wrote:
    I consistently get a (connection refused) error.
    IP_CLIENT_OPEN requires a LONG and not a literal string for the server port parameter.

    Try changing:
    IP_CLIENT_OPEN(dvIPClient.Port,'192.168.254.30','8000',1)

    To:
    IP_CLIENT_OPEN(dvIPClient.Port,'192.168.254.30',8000,1)
  • billyungbillyung Posts: 16
    Joe,
    Thank you so much for the quick fix! I changed the parameter type to a long from a string literal and it works fine. I felt bad about asking for help ( and wasting so much time ) on such a simple problem so I looked back at the documentation. I found the Netlinx documentation doesn't specify parameter types for the IP_Client_Open command. Curious... Even more curious is the fact that the compiler doesn't puke up a "type mismatch" error or warning.

    Anyway, having gotten through that issue, I am now sending commands and receiving responses via IP from the MAX without using the module. This is probably just as basic a problem but it's absolutely killing me! The response the MAX is sending back is always {Error : 1} which means invalid parameter. I've tried command as basic as simply "Status" with the same result. I've tried all forms of carraige returns including $0D, 13 and \r with no luck.

    If you could provide me with just a snippet of working code that shows a command being sent to the MAX (bypassing the module) and a response being captured, (doesn't matter which command) it would end my 3 day odyssey of trying to send a simple message back and forth. I accomplished this with Lasso (PHP like web script) in 5 minutes. I have 5 hours (at least) into doing the same thing in Netlinx. I'm quite frustrated with it. I'm glad AMX has put up these forums and I certainly appreciate folks like you that help out guys like me that only do half a dozen Netlinx projects a year while working daily in other languages.

    Bill
  • Joe HebertJoe Hebert Posts: 2,159
    Bill,

    Are you using the built in help file with Netlinx Studio? In your source code double click IP_CLIENT_OPEN to highlight it, press F1, and you?ll find your way to the syntax which includes the parameter types.

    It sounds like you have 2-way comms satisfied which is the first step. You didn?t post your exact code but I think you may be using the wrong command for status. The DVD commands are at the bottom of the document. This is the string I used for status:

    SEND_STRING dvMax,"'dvd status 1?,13?

    Give that a whirl and see where it takes you.
  • billyungbillyung Posts: 16
    Joe,

    I really appreciate the time you've taken to help me out so far. Unfortunately, I'm still getting only an {ERROR: 1} as a response. I know sometimes you have to insert a "handle" into some of the commands for the MAX which means adding an extra parameter such as "1|" prior to the first documented parameter. I have tried some commands with and without the extra handle and still the same. The thing that kills me is the commands work fine when coming from other languages. I just can't get it to return valid responses while using Netlinx. I'm sure it's something stupide I'm doing (or not doing ). It's just frustrating at this point.
    DEFINE_CONSTANT
    nIPPort = 8000
    
    DEFINE DEVICE
    dvIPClient = 0:2:0
    
    DEFINE EVENT
    BUTTON_EVENT[dvTP01_4, 112]	// Get DVD Details
    {
      PUSH :
        {
    	(* Open The Client *)
    
    	IP_CLIENT_OPEN(dvIPClient.Port,'192.168.254.30',nIPPort,1)
    	wait_until(maxiponline) //set to 1 in online max ip event, 0 in offline event
    	    {
    	    SEND_STRING 0,"'Opening tcp port for Max'"
    		wait(2)
    		{
    
    		    SEND_STRING dvIPClient.PORT,"'dvd status 1',13"
    		    SEND_STRING 0,"'Getting DVD Details for DVD #', SelectedDVDID"
    		}
    	    }
    	SEND_COMMAND dvTP01_4,"'PPON-','MMS Details'"
    
        }  
    }
    

    Here is the event handler which all seems fine as I'm connecting and disconnecting, sending commands and receiving responses just fine. I'm just getting a persistent error message as a response to every command. Odd...
    DEFINE_EVENT
    
    (* MAX IP Data Handler *)
    
    DATA_EVENT[dvIPClient]
    {
        ONERROR:
        {
        SEND_STRING 0,"'Device ',DEV_TO_STRING(DATA.Device),':',GET_IP_ERROR(DATA.Number),13,10"
        }
    
        ONLINE:
        {
        maxiponline=1
        }
    
        OFFLINE:
        {
        maxiponline=0
        SEND_STRING 0,"'MAX IP Connection dropped.'"
        }
    
        STRING:
        {
        send_command dvTP01_4, "'TEXT97-', Data.Text"
        SEND_STRING 0,"'string: client=',Data.Text"
        if(maxiponline)
           {
            IP_CLIENT_CLOSE (dvIPClient.port)
           } 
        }
    
    }
    

    Here's the diagnostic output in which I am manipulating port 16 while port 4 is in use by the COMM module. I have also tried disabling the COMM module with no difference in the result:

    Line 1 :: SendString to socket-local port (16) invalid - 22:10:24
    Line 2 :: CIpEvent::OnError 0:16:3 - 22:10:24
    Line 3 :: Device 0:16:3:IP ERROR (17): Local port not open$0D$0A - 22:10:24
    Line 4 :: Connected Successfully - 22:10:26
    Line 5 :: Memory Available = 21998776 <14508> - 22:10:26
    Line 6 :: CIpEvent::OnLine 0:16:3 - 22:10:26
    Line 7 :: Opening tcp port for Max - 22:10:26
    Line 8 :: Getting DVD Details for DVD #1 - 22:10:26
    Line 9 :: Connected Successfully - 22:10:27
    Line 10 :: Memory Available = 21982936 <15840> - 22:10:27
    Line 11 :: CIpEvent::OnLine 0:4:3 - 22:10:27
    Line 12 :: Exiting TCP Read thread - closing this socket for local port 16 - 22:10:29
    Line 13 :: string: client={ERROR: 1} - 22:10:29
    Line 14 :: Closing IP port - 22:10:29
    Line 15 :: CIpSocketMan::ProcessPLPacket - Socket Already Closed - 22:10:29
    Line 16 :: CIpEvent::OffLine 0:16:3 - 22:10:29
    Line 17 :: MAX IP Connection dropped. - 22:10:29
    Line 18 :: CIpEvent::OnError 0:16:3 - 22:10:29
    Line 19 :: Device 0:16:3:$0D$0A - 22:10:29
    Line 20 :: Exiting TCP Read thread - closing this socket for local port 4 - 22:10:29
    Line 21 :: CIpEvent::OffLine 0:4:3 - 22:10:29
    Line 22 :: Connected Successfully - 22:10:31
    Line 23 :: CIpEvent::OnLine 0:4:3 - 22:10:31
    Line 24 :: Exiting TCP Read thread - closing this socket for local port 4 - 22:10:31
    Line 25 :: CIpEvent::OffLine 0:4:3 - 22:10:31



    Thanks for any advice you might offer. Thanks also for the tip on the help function. Again, my mistake. I read the help chapter on IP communications and it's within that chapter that no parameter types are given. They are certainly there if you search the help resource as you suggest.

    I may want to add that I'm on MMS version 3.3.8 which is the latest version and the commands I'm sending work within the shell using the cmd program.

    Thanks,


    Bill
  • Joe HebertJoe Hebert Posts: 2,159
    Bill,

    SEND_STRING dvIPClient.PORT,"'dvd status 1',13"

    Should be:
    SEND_STRING dvIPClient,"'dvd status 1',13"

    Where is local port 16 coming from? And what Comm module is using port 4, the MAX COMM? As Dave mentioned earlier, you should either dump the AMX MAX COMM module and control it yourself or use the PASSTHRU command with the module ? not both.
Sign In or Register to comment.