IP Control of a Device
remeolb
Posts: 79
I have spent 2 hours searching and I can't seem to find a comprehensive beginner's guide to control a device over IP. I finished P2 a few months ago and we just barely touched on this subject. I am trying to control both a surround processor and a projector with IP. How do I set up the communication for the devices? How do I define the devices? Where do I tell the master the IP addresses of the devices I am controlling?
I would really appreciate some basic example code of what I need to get started. Any help would be much appreciated.
I would really appreciate some basic example code of what I need to get started. Any help would be much appreciated.
0
Comments
PROGRAM_NAME='VANTAGE'
DEFINE_DEVICE
dvVANTAGE = 0:3:0 //VANTAGE SYSTEM ip device
DEFINE_CONSTANT //Constants for opening the port used below
CHAR sIPVANTAGE [] = '10.0.0.16' //The vantage IP address
svPORT = 3001 //Vantage port number
IP_TCP = 1 //this means be TCP instead of UDP
DEFINE_START //This is where I open the port so I can send strings to it
WAIT 25
{
IP_CLIENT_OPEN (dvVANTAGE.PORT, sIPVANTAGE,svPORT,IP_TCP)
}
Your device is the server, so you only have to open a client. Unless, of course, you are writing the device end too. You would only need to open a server if you are putting your master in a "listen" type of mode, and the devices are taking the initiative to connect to it.
The problem I am now running into is I can't seem to send the surround processor strings. If I send it a string that I know works through RS-232 it does nothing. And the send string 0 I have set up in the string event does not send the string I sent it to diagnostics. Should I not be able to use control a device and send a string to 0:4:1? Am I doing something wrong? What is the correct way to send the surround processor strings to control it once I have my client set up?
That is the correct method: send_string 0:4:1, <string goes here>. Send_string 0 just goes to your terminal screen, that won't go to the device at all. However, there is no guarantee that the IP protocol is the same as the RS-232 protocol. If often is, but there are sometimes subtle differences, and sometimes they aren't even remotely the same. What device are you controlling? Maybe someone here knows. If it's a Lutron, for example, a simple CR at the end of the command (Hex $0D) works for the RS-232 port, but if you are using IP, it requires a CRLF pair (hex $0D, $0A) ... just the CR alone won't do anything.
It's those little things that always get you. By the way, that might be a good thing to try, adding an LF to your terminator.