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

Login:
Pass:
 
 

Topic:
ReferenceError
This thread has 9 replies. Displaying all posts.
Post 1 made on Sunday December 30, 2007 at 04:09
jacovn
Long Time Member
Joined:
Posts:
December 2007
33
After trying to understand basic concepts and confirming my setup works with adding a RS-232 string to a button and see that that actually does thing on a serial connected device.

I wanted to do the same thing with Prontoscrip.

I think i make a very dumb mistake here, but i cannot resolve it. I have searched the whole Pronto Professional section but i turned up with not a solution.


In the properties of a device i have the following piece of script:

PowerOn = function()
{
var extender0 = CF.extender[0];
if( extender0 == null )
{
Diagnostics.log("Extender 0 is not defined");
}
else
{
var rs232port1 = extender0.serial[0];
if( rs232port1 == null )
{
Diagnostics.log("Extender 0 is not a serial extender");
}
else
{
rs232port1.bitrate = 9600;
rs232port1.databits = 8;
rs232port1.parity = 0; // None
rs232port1.stopbits = 1;
var response;
var command = "%";
response = rs232port1.send(command);
}
}
)


In a button in a page which is under the device i have the folowing code:

PowerOn();



When i execute this i get:

ProntoScript error:ReferenceError:PowerOn is not defined
Offending Button script: Tag 'poweron'
Offending Line#1 "PowerOn;"

It looks as if the function is not know when i call it from my button script.
I thought the functions on the device/activity level should be know when i enter this device ?
Post 2 made on Sunday December 30, 2007 at 08:00
frankbe
Long Time Member
Joined:
Posts:
December 2007
10
did you try
function PowernOn()

instead of
PowerOn = function()

Ciao

Frank
Post 3 made on Sunday December 30, 2007 at 10:57
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,006
PowerOn = function()
{
...
}

Actually creates a function in the Activity Object named PowerOn. You should be able to access this function as CF.activity().PowerOn().

However, if you follow frankbe's lead and change to function PowerOn() you will be able to find the PowerOn() function directly from the button.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 4 made on Sunday December 30, 2007 at 12:00
jacovn
Long Time Member
Joined:
Posts:
December 2007
33
duh.. i knew it was something stupid, but soo stupid, thanks (ashamed)
OP | Post 5 made on Monday December 31, 2007 at 02:29
jacovn
Long Time Member
Joined:
Posts:
December 2007
33
Well made it more simple (and more correct i hope)


properties of Device, advanced tag, prontoscriptname: justfortest

// serial commands
var extender0 = CF.extender[0];
if( extender0 == null )
{
Diagnostics.log("Extender 0 is not defined");
}
else
{
var rs232port1 = extender0.serial[0];
if( rs232port1 == null )
{
Diagnostics.log("Extender 0 is not a serial extender");
}
else
{
rs232port1.bitrate = 9600;
rs232port1.databits = 8;
rs232port1.parity = 0; // None
rs232port1.stopbits = 1;
}
}


function SerialPowerOn()
{
var command = "%";
var response = rs232port1.send(command);
}


function SerialPowerOff()
{
var command = "$";
var response = rs232port1.send(command);
}

And under the buttons:
SerialPowerOn();
SerialPowerOff();


edit:
It now works, thanks. I had still 2 wrong brackets ) in stead of } there so the function never ended properly.
The world looks better now :)

Last edited by jacovn on December 31, 2007 05:26.
Post 6 made on Monday December 31, 2007 at 12:37
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,006
Wow, That looks pretty much like the example in the Dev Guide.

Note that since you are not using 2-way RS232, you could have just as easily coded this as RS232 actions in your config instead of resorting to Prontoscript.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 7 made on Tuesday January 1, 2008 at 03:40
jacovn
Long Time Member
Joined:
Posts:
December 2007
33
Lyndel, indeed, i started with much to fancy idea's but since that failed it thought i better fallback to a simple example to verify it is working.
I see now my videoscaler switch on and off. That is only 1 way but i see it working so i plan to go foreward with small steps.

My 2 way devices are a Meridian Pre-amp with a very hard protocol and a JVC videoprojector with a not to bad protocol.
The Meridian sends a 'ack' for every command you send, which is in basis the command you send out. But also it sends the result of the action and sometimes it sends out the whole display string.
The JVC is simpler, you get dependng on the kind of command you send either a 'ack' or a 'ack' and an answer.

On they other hand i have made all my channel icons and i have all the IR codes i need ready (either learned or generated) so i do not have to ask questions about them..
Post 8 made on Tuesday January 1, 2008 at 04:40
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,006
jacovn,

I hope you did not misinterpret my reply. I was not belittling you, nor did I intend to do so, an any way. I think it's great that you and other folks are starting to come up to speed on ProntoScript.

Your understanding of the programming required is most excellent. Why do I say this? Because you have begun to think about protocols and difficulties you will encounter based on the message set as well as considerations for the message transport (232 vs IP).

As you also pointed out above, the protocol that provides a single response for every command indeed lends itself ease of programming with serial.match() whereas others that send an ACK, followed by a 2nd message (Event String) are more difficult to program as you have to have a timing loop and periodically poll the RS-232 port.

Using TCP, you can better handle this type of message set because TCP comes straight to Pronto with no buffering and can be handled asynchronously whereas RS-232 requires that you poll the extender.

It is for this reason that I wrote an Activity to communicate with my Denon 5805 via TCP/IP. I have one for RS-232 but it is not nearly as speedy as the one for TCP/IP.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 9 made on Tuesday January 1, 2008 at 06:10
jacovn
Long Time Member
Joined:
Posts:
December 2007
33
Lyndel,
I hope my reaction was not taken wrong. English is not my mother language, and i am gratefull for all the great help i get here.

I did learn to program on school, but that was like 15 years ago. I design Wide Area Computer networks for a living these days, so i have to get back into coding.

I have all kinds of idea's floating around in my head with all the great things i could do with the TSU9600 and 2 way communication.
I have to take care that i do not start with to many things at once.

So i started of with reading a lot of threads on this forum, and the ProntoScript Developers guide. Since my programming skills most likely are not up to data any more (programming was more sequential when i was at school) i was happy to find the thread Barry made on bullitproofing a interface.
I do know from the past that working from a good basic framework can spare you a lot of problems later on in the process.

Since there is not a complete framework layed out, but only an idea on how you could do it, i thought it was best to trying out basic examples so i can get an idea of how it all works.

I am quite happy if something works, that gives me energy to try the next step.

The 2-way is conceptual not a great problem for me i think.
Getting the syntax right, and understanding what operations are allowed on what data types is more a problem. But with help of a Java editor and just trying things out i will get there i hope.

Unfortunately i am stuck with RS-232 and IR for all my devices. IP is not yet so much used in the devices i have in my Home Theater. And also i do review equipment for a magazine and there i hardly see ethernet interfaces yet. And when they have it, it is often for streaming content or software upgrades.

But i do thing it is the way to go, and we will see more and more TCP/IP connectivity.
Post 10 made on Tuesday January 1, 2008 at 15:53
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,006
On January 1, 2008 at 06:10, jacovn said...
I have all kinds of idea's floating around in my head
with all the great things i could do with the TSU9600
and 2 way communication.
I have to take care that i do not start with to many things
at once.

Welcome to my world. Too many projects, not enough time.
Lyndel McGee
Philips Pronto Addict/Beta Tester


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