Home AMX User Forum NetLinx Studio

Sony PCS-11

Hi all, I am a new programer for AMX. Can someone please tell me how I can sent command through IP? I know there is a module from AMX for PCS-11, as I only need some of the function in my programme it would be easier to just add in the few command.

Thank you.

Comments

  • Sony PCS-11 (TCP)

    Assuming you are using Netlinx, here is a very basic skeleton of what needs to be done (exercise left to the reader for more complex applications). I am sure I will blow something in the syntax and someone will correct me and hopefully others will have some suggestions on how they implement TCP/UDP connectivity.
    DEFINE_DEVICE
    
    dvTCP = 0:2:0   // pick a device number
    
    dvTP  = 10001:1:0  // for example
    
    DEFINE_VARIABLE
    
    CONSTANT INTEGER nTCP = 1
    
    VOLATILE LONG lReturn
    VOLATILE LONG lDevicePort = 100
    
    VOLATILE CHAR cIPAddress[] = '192.168.1.100'
    
    DEFINE_START
    
    lReturn = IP_CLIENT_OPEN(dvTCP.Port, cIPAddress, lDevicePort, nTCP)
    
    // check return value for error here
    
    

    Note - a lot of detail is being glossed over here. Your choice of TCP device can start at 0:2:0 and can be an arbitrary port above it but it should be unique - it should not be used for another TCP or UDP connection at the same time. Further, sequentially allocate your network ports in Netlinx since memory is allocated to manage them up to the largest port allocated regardless of whether all of them are used. For example, if you decided to use 0:200:0 and this was your only network device, you just wasted a lot of memory.

    The IP_CLIENT_OPEN() call takes the TCP port as the 1st argument, the IP address of the server (device), the port on which the device is listening, and lastly a flag indicating whether or not the connection will use TCP or UDP. I used TCP in this example.

    Note also that I put the IP_CLIENT_OPEN() call in DEFINE_START for the program - you could put it in a TIMELINE, an event handler, or anywhere that it makes sense for your application. Naturally, the TCP device can not be used until the connection is established (generation of the ONLINE event).

    The IP_CLIENT_OPEN() call will return a status indicator letting you know if the call failed and if so the reason for it. If a successful connection is made, you will get an ONLINE event for the device:
    DATA_EVENT[dvTCP]
    {
      ONLINE:
      {
        // now it is ok to send data to the port
      }
    }
    
    

    Now, you have opened a connection to your device and are connected to it. You can now send data (commands) to the device as part of any event you like such as a BUTTON_EVENT:
    BUTTON_EVENT[dvTP, 1]
    {
      PUSH:
      {
        SEND_STRING dvTCP,"' ... command ...'"
      }
    }
    
    

    Again, this is a real basic introduction. The Netlinx programming manual has some excellent examples on how to communicate using TCP/UDP and I would suggest reading the manual. You will also want to include ONERROR handlers in the DATA_EVENT and in the event you expect to receive data from the device, your DATA_EVENT handler for dvTCP should include a STRING handler and appropriate parsing code for it. My example is based on opening a connection to the device and keeping the connection open - this may or may not be appropriate for your application/device. You could open the connection, send the command, and close the connection each time if commands are sent infrequently. Your choice of TCP or UDP will largely depend on what your device supports. I am not familiar with the Sony PCS-11 so I can't help in that regard.

    Hope this helps.
  • Sorry for the late reply. I have try out the programme and are able to see my decive online through telnet. But the problem I face now is that the command is not senting over to PCS-11. Apart from opening the port, I have to log in to PCS-11 and sent a "cntr" command before it will respond from external control. I have try control it from my laptop telnet and it works. I don't know if I have enter in the wrong command in my AMX programme. I have attach the programme below, please correct me if anyone know where I am wrong. Thank you.

    DEFINE_DEVICE
    dvVC = 0:2:0 (**** SONY VC *******)
    vdvTP = 33001:1:1
    dvWEB = 3001:1:1

    DEFINE_COMBINE (vdvTP,dvWEB)
    DEFINE_VARIABLE

    CONSTANT INTEGER nTCP = 1

    VOLATILE LONG lReturn
    VOLATILE LONG lDevicePort = 23

    VOLATILE CHAR cIPAddress[] = '192.168.0.130'
    DEFINE_START

    lReturn = IP_CLIENT_OPEN(dvVC.Port, cIPAddress, lDevicePort, nTCP)
    DEFINE_EVENT

    DATA_EVENT[dvVC]
    {
    ONLINE:
    {
    SEND_STRING 0,"'VC are online'"
    }

    OFFLINE:
    {
    SEND_STRING 0,"'VC are offline'"
    }

    STRING:
    {
    SEND_STRING dvVC,"'sonypcs',13,10"
    SEND_STRING dvVC,"13,10"
    SEND_STRING dvVC,"'cntr',13,10"
    }
    }

    BUTTON_EVENT[vdvTP,1]
    {
    PUSH:
    IP_CLIENT_OPEN(dvVC.Port, cIPAddress, lDevicePort, nTCP)
    }

    BUTTON_EVENT[vdvTP,2]
    {
    PUSH:
    SEND_STRING dvVC,"'stand-by',13,10"
    }
  • Sony PCS-11

    If I understand correctly, the sequence of SEND_STRINGs to the device in the DATA_EVENT are the login sequence. Putting them in the STRING handler means that these SEND_STRINGs will only be sent to the device when a STRING is received from the device. If the device will not respond until you issue these commands, move them to the ONLINE handler so they are executed once the connection is made. If you want to process strings from the device, I would create a buffer using CREATE_BUFFER and then parse the responses under the STRING handler in the DATA_EVENT. If the Sony device is not going to respond to your program until you send the 3 strings in the STRING handler, this would explain part of your problem.

    Also, I noticed you have an IP_CLIENT_OPEN() call under a button event. If your connection to the Sony device is persistent, then that 2nd open would be redundant. However, if you wanted to use the BUTTON_EVENT that would do an open and add another that would do an IP_CLIENT_CLOSE(), then you could program a touchpanel to open and close the device as you wished.

    The second BUTTON_EVENT, used for the standby command, is good. You can create button events for any commands you wish to send to the device provided you have opened the device first and in your case performed the login under the ONLINE handler. You may wish to set a flag in the ONLINE handler indicating the device is online and clear that flag in the OFFLINE handler. You can then check this flag before sending any commands to the device to make sure the device is connected beforehand.

    Hope this helps.
  • Sony PCS-11

    I neglected to ask a basic question - did your program successfully connect to the device (you observed the 'VC are ONLINE' message)? If not, then you need to look at the connection parameters. If you did successfully connect to the device, moving the strings to the ONLINE handler should help.

    Additionally, does the Sony require any type of delay between commands? If so, you may need to pace the commands sent to the device so that they are not sent faster than the device can process them. This is typically more of a problem associated with RS232 devices but it is worth a mention here.
Sign In or Register to comment.