Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Original thread:
Post 3 made on Sunday June 13, 2010 at 05:20
PsyenceFact
Lurking Member
Joined:
Posts:
June 2010
8
I'm working with the OP and wrote the ProntoScript for this project so it's probably easier for me to add some more detail.

The GC-100 is being used to send IR commands to various source boxes (SkyHd, Blu-Ray player, etc).  It uses a single TCP socket for communicating with all 6 IR outputs.  This may be accessed from any of the Prontos at any time as it is a multi-user system.  Because of this, the socket must be closed by the Pronto after each command group is sent.  The GC-100 responds to a command with either a success or error message; once this is received by the Pronto, the socket is closed.  The Pronto socket is asynchronous, and the closing occurs in the onData function.

An outline of the code is below.  This sits at the activity level.  The variable avSource is an activity-level object which contains IP address, TCP port, etc.  The function avSourceSendData is called from the main state machine loop when conditions allow.  The loop runs every 100 ms and is driven by the page script.  When the machine enters the BUSY state and sends an IR command, a timer is started.  If this gets to 5000 ms with no response being received, it is assumed that the connection to the GC-100 has been lost and an error is generated.

The behaviour we are seeing is intermittent as described above.  Much of the time, the IR command sends successfully within a single machine loop and occasionally a timeout error occurs.  However, it is more common for nothing to happen until the BUSY timer passes 3000 ms at which point a response is recevied and normal service resumed - this is the 3 second delay referred to by the OP.

I believe that the delay occurs during the initialisation and connection of the TCP sockets and am investigating that further.  However, if this is a phenomenon that anyone else has encountered I'd be keen to hear about it (and how you got round it).

Many thanks,

Andy

// Begin code
function avSourceOnConnect() {
    if (avSource.command !== null) {
        avSourceSendData();
    }
}
function avSourceOnData() {
    try {
        if (avSource.socket.read(30) != avSource.response) {
            generateError("Unexpected AV source return value");
        } else {
            System.print(avSource.response);
        }
    }
    catch(e) {
        generateError("Unable to read from AV source");
    }
    finally {
        avSource.socket.close();
        avSource.socket = null;
        iState = "IDLE";
    }
}
function avSourceInitSocket() {
    try {
        if (avSource.socket) {
            avSource.socket.close();
        }
        avSource.socket = new TCPSocket(false);
        avSource.socket.onConnect = avSourceOnConnect;
        avSource.socket.onData = avSourceOnData;
        avSource.socket.onClose = avSourceOnClose;
        avSource.socket.onIOError = avSourceOnIOError;

        avSource.socket.connect(avSource.ipaddress, avSource.tcpport, 2000);
    }
    catch(e) {
        generateError("Unable to initialise AV source socket");
    }
}
function avSourceSendData() {
    if (avSource.socket && avSource.socket.connected) {
        try {
            avSource.socket.write(avSource.command);
        }
        catch(e) {
            generateError("Unable to send IR command to AV source");
        }
    } else {
        avSourceInitSocket();
    }
}
// End code


Hosting Services by ipHouse