Pronto Javascript

The place where software developers meet

Moderator: marcus

Pronto Javascript

Postby Snelvuur » Sun 27. Mar 2011, 03:12

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
Snelvuur
 
Posts: 15
Joined: Sat 20. Jun 2009, 16:10

Re: Pronto Javascript

Postby 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.
Snelvuur
 
Posts: 15
Joined: Sat 20. Jun 2009, 16:10

Re: Pronto Javascript

Postby IRTrans » Mon 4. Apr 2011, 11:12

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
IRTrans
Administrator
 
Posts: 2115
Joined: Mon 21. Apr 2008, 23:32

Re: Pronto Javascript

Postby Snelvuur » Mon 4. Apr 2011, 22:32

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();
}
Snelvuur
 
Posts: 15
Joined: Sat 20. Jun 2009, 16:10

Re: Pronto Javascript

Postby IRTrans » Mon 4. Apr 2011, 23:21

Hi,
thank you for that.

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

IRTrans
IRTrans
Administrator
 
Posts: 2115
Joined: Mon 21. Apr 2008, 23:32

Re: Pronto Javascript

Postby Snelvuur » Tue 5. Apr 2011, 11:34

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.
Snelvuur
 
Posts: 15
Joined: Sat 20. Jun 2009, 16:10


Return to APIs

Who is online

Users browsing this forum: No registered users and 11 guests

cron