by Snelvuur » Sun 3. Apr 2011, 21:28
Ok, got a bit further.. On the pronto you can assign prontoscript to a button for instance. Do "TCPSend("hs2_signals","91");" where hs2_signals is the device and 91 the function (i have numbers, but for others it could be called channel_up for instance)
then utilizing this code:
var IPAddress="192.168.1.50";
var Port="21000";
var Timeout="20";
var str = "";
var receivedText = "";
function reInitSocket()
{
socket = new TCPSocket();
socket.onConnect = onConnect;
socket.onData = onData;
socket.onClose = onClose;
socket.onIOError = onIOError;
socket.connect(IPAddress, Port, Timeout);
}
function onTimeout()
{
reInitSocket();
}
function onConnect(){
System.print("Connected.");
if ( socket ) { socket.write( str ); }
else {System.print("onConnect: No Socket"); }
}
function onData(){
System.print("Ondata.");
receivedText += socket.read();
socket.close();
socket = null;
}
function onClose(){
System.print("onClose Event: Socket closed by IRtrans");
socket = null;
}
function onIOError(e){
System.print("Socket error, closing socket");
socket.close(); socket = null;
}
function TCPSend(dvc,cmd){
str = "ASCIAsnd "+dvc+","+cmd+"\r";
reInitSocket();
}
This works and allows me to zap really fast with my pronto and irtrans. However after a certain number of correct calls (say around 15 to 20) it stops working. I have to restart the Irtrans LAN tray icon for it to work again.
Am i missing something here? Is there any setting i need to change? Its not like it locks up and then returns to normal, i have to restart the tray icon in order for it to work again.