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

Login:
Pass:
 
 

Page 1 of 2
Topic:
Pronto Script - TCP send data
This thread has 15 replies. Displaying all posts.
Post 1 made on Tuesday June 15, 2010 at 09:16
boriss
Lurking Member
Joined:
Posts:
June 2010
3
Hello,

I want to program a button via Pronto Script, so that when I push the button, Pronto TSU 9600 sends a command over TCP.

It has to open port on unit with IP address 192.168.5.95 on port 55957 and send
byte[] ondata = {0x02,0x08,0x07,0x01,0x01,0x00,0x01,0xFF,0x13};

And close the port.

Can anyone help me?
Post 2 made on Tuesday June 15, 2010 at 12:03
BluPhenix
Long Time Member
Joined:
Posts:
December 2008
371
Played with it just today, like it says in the dev. guide:

var socket = new TCPSocket(false); //sync operation
socket.connect("192.168.5.95", 55957, 3000);
socket.write(your_string);
socket.read(nr_of_bytes, 3000);
socket.close();

This is the basic way.

Any particular reason the data is in an array? You must convert the array to a string.
Post 3 made on Tuesday June 15, 2010 at 21:32
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
You may want to go to www.the-gordons.net and click 'downloads'. There are some tutorial documents that Barry has put together that will help you better understand data communications on the Pronto.

Here's the link. In the left-hand frame, you want the Pronto Communications document. Ignore the fact that it states it is for serial communications.

[Link: the-gordons.net]
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 4 made on Wednesday June 16, 2010 at 01:17
wall-e
Long Time Member
Joined:
Posts:
September 2008
55
Looks like a usefull resource!
OP | Post 5 made on Wednesday June 16, 2010 at 02:52
boriss
Lurking Member
Joined:
Posts:
June 2010
3
BluPhenix
Well, I have commands for this device only in array. Do you know how to change the array in string?

Lyndel McGee
Thank you for the link, the good idea is debugging panel, but I don't know how to enable variables, so that I can see the TCPIP traffic.

Last edited by boriss on June 16, 2010 03:12.
Post 6 made on Wednesday June 16, 2010 at 03:32
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
The part you should be interested in is String.fromCharCode() on pages 12 and 13 of the document you read plus the example that builds a string with checksum on the end. The checksum is not pertinent but the suggestion of using String.fromCharCode() is. In a looping fashion, it can be used to build a string.

var arr = [0x02,0x08,0x07,0x01,0x01,0x00,0x01,0xFF,0x13];
var stringToSend = '';
var i;
for (i = 0; i < arr.length; i++)
stringToSend += String.fromCharCode(arr[i]);

If you are going to be doing ProntoScript for a living, you owe it to yourself, if you are not familiar with Javascript to purchase the Flanagan book referenced in the Dev Guide as a resource and read chapters 1-10 as they are an excellent resource for things you will see. You might also want to work through the examples in the Dev Guide, become Level 1 Certified on Philips site such that you can download modules and examine the code inside to see how they work.

Here is an excellent Javascript reference.

[Link: w3schools.com]

Be aware that this does not include some of the latest Array functions that were introduced in Javascript 1.6 which the Pronto uses.

You can find more info on the Mozilla site as well:

[Link: developer.mozilla.org]

The forEach method for an array might pique your interest as well. Note that the mechanism of forEach is slower than the example I posted above.

[Link: developer.mozilla.org]

Last edited by Lyndel McGee on June 16, 2010 03:40.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 7 made on Wednesday June 16, 2010 at 06:30
boriss
Lurking Member
Joined:
Posts:
June 2010
3
Ok,

I did my best, even thou my knowledge of Pronto script is on the beginners level.

I inserted u button with PS Action:

var arr = [0x02,0x08,0x07,0x01,0x01,0x00,0x01,0xFF,0x13];
var stringToSend = '';
var i;
for (i = 0; i < arr.length; i++)
stringToSend += String.fromCharCode(arr[i]);

var socket = new TCPSocket(false); //sync operation
socket.connect("192.168.5.95", 55957, 3000);
socket.write(stringToSend);
socket.read(100, 3000);
socket.close();

and get next error:
ProntoScript error: Socket error
Offending button script: (untaged)
Offending line #8: "socket.write(stringToSend);"

Again, please help
Post 8 made on Wednesday June 16, 2010 at 06:51
sWORDs
Long Time Member
Joined:
Posts:
November 2006
373
socket=new TCPSocket(false);
socket.onConnect=function(){
     socket.write("\x02\x08\x07\x01\x01\x00\x01\xFF\x13");
     socket.close();
};
socket.connect("192.168.5.95",55957,3000);

Last edited by sWORDs on June 16, 2010 07:06.
Post 9 made on Sunday October 24, 2010 at 07:36
oferpeleg
Long Time Member
Joined:
Posts:
November 2003
34
On June 16, 2010 at 06:51, sWORDs said...
socket=new TCPSocket(false);
socket.onConnect=function(){
socket.write("\x02\x08\x07\x01\x01\x00\x01\xFF\x13");
socket.close();
};
socket.connect("192.168.5.95",55957,3000);

I'm trying to do the same (sending a simple string trough TCP/IP)

While using the code above I'm getting the following error :

"ProntoScript error: Failed to connect
Offending button script: Tag: 'TEST1'
Offending line #5: "socket.connect("192.168.1.197",10001,3000); "

What is the problem ?
Post 10 made on Sunday October 24, 2010 at 10:01
b00bie
Founding Member
Joined:
Posts:
July 2001
396
Looks like 192.168.1.197 on port 10001 is not listening for socket connections. Are you sure that the pronto is on the same subnet?

Last edited by b00bie on October 24, 2010 10:12.
Post 11 made on Sunday October 24, 2010 at 11:08
BluPhenix
Long Time Member
Joined:
Posts:
December 2008
371
What are you trying to connect to? What B00bie said is correct, it could mean that the device you want to connecto to is not listening on the port 10001 or that there is a general problem with the connectivity.

Try pinging (if you have the option) the TSU from the device you want the pronto to connect to, to ensure the two see each other on the network.
Post 12 made on Sunday October 24, 2010 at 12:55
oferpeleg
Long Time Member
Joined:
Posts:
November 2003
34
The Pronto,Computer and the Alarm system that I’m trying to connect to , is on the same network and the same subnet.

I can send TCP strings trough my PC (RS232-TCP software) to the same IP and Port and it's working ...

The error is showing on the ProntoScript Console .

The syntax is correct ?
Post 13 made on Sunday October 24, 2010 at 14:22
Eddi
Lurking Member
Joined:
Posts:
October 2009
7
Ofer try to use Synchronous connection first...
that worked for me with few devices
Post 14 made on Sunday October 24, 2010 at 18:28
BluPhenix
Long Time Member
Joined:
Posts:
December 2008
371
Try increasing the timeout.

The code is right and should work. To be completely sure what is happening with the connection yu should chack the lan traffic with wireshark or something similar.

Can you provide any more data.

Another thought, maybe the device is expecting a UDP connection on that port, you can try this as well. Or try looking with wireshark how the communication between the PC and device look like.
Post 15 made on Monday October 25, 2010 at 06:13
sWORDs
Long Time Member
Joined:
Posts:
November 2006
373
You'll probably will need to use a carriage return and/or line feed at the end once you've got it working.
Page 1 of 2


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse