Page 1 of 1

Pronto Javascript

PostPosted: Sun 27. Mar 2011, 03:12
by Snelvuur
I know more people out there have a Pronto, i have the tsu9600 for instance. I use homeseer in combinatin with the irtrans plugin. But when "zapping" through channels it just takes too long.

My question, does anybody out there have the pronto javascript example of making a call directly towards the irtrans via tcp? That would take out homeseer and should improve speeds.
Doesn't have to be pronto javascript (just plain old javascript example from something else is fine too) since it should work in the pronto too.

Thanks,
Eric

Re: Pronto Javascript

PostPosted: Sun 3. Apr 2011, 21:28
by Snelvuur
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.

Re: Pronto Javascript

PostPosted: Mon 4. Apr 2011, 11:12
by IRTrans
That looks like the socket is not closed correctly.

Anyways, simply use UDP for it. Then you can directly send an IR code by sending "snd remote,command" to port 21000 of the IRTrans device.

IRTrans

Re: Pronto Javascript

PostPosted: Mon 4. Apr 2011, 22:32
by Snelvuur
For the people that want to use irtrans with pronto directly, this code works now and correctly terminates the tcp so my last bug is gone:

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(5000,1000);
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();
}

Re: Pronto Javascript

PostPosted: Mon 4. Apr 2011, 23:21
by IRTrans
Hi,
thank you for that.

However, I would still recommend to change the code to UDP - that is a lot faster and easier.

IRTrans

Re: Pronto Javascript

PostPosted: Tue 5. Apr 2011, 11:34
by Snelvuur
I wish i could, even though the pronto has UDP in its foundation to detect extenders on the network. You cannot access the functionality through prontoscript, so we are left with tcp only. But i have to say that its fast enough to not notice a big difference.