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:
Periodically running stuff possible?
This thread has 10 replies. Displaying all posts.
Post 1 made on Thursday March 14, 2019 at 08:43
sebastian
Long Time Member
Joined:
Posts:
September 2003
43
Hi,
I had a little time fiddling with ProntoScript today and wrote a few lines to report the battery status of my 9800 back to my home automation software.
Now I'm looking for a way to update the report maybe every hour or so.
I would also be good if this only happend when the device is awake (or maybe also each time it wakes up).

As I see it now, that's not really possible, is it?
As all the code is only running in a specific activity's context, I'd have to copy the same code to all activities, right?
Or is there some way to use onSleep()/onWake() or scheduleAfter() on a system level?

Sebastian
Post 2 made on Thursday March 14, 2019 at 19:16
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,279
You'd have to write a ProntoScript Module and include it at the System Level. Then each activity would get this module.

Note that this only works with PEP2 as this is where modules were introduced.

Now, with regard to how the Pronto operates.

1. When docked, even though the screen is off, ProntoScript is able to run continuously.

2. When undocked, Pronto CPU goes into a semi-sleep mode effectively waking up every minute or so to keep wifi active. When this happens, some ProntoScript can start to run and then be suspended again.

So, now, a very terse example.

Put this closurecode into a JS file and include it from the System Activity. It will be run for every activity in the configuration.


((function(){
System.setDebugMask(9);
// the current activity.
var myActivity = CF.activity();
myActivity.onSleep = function(){
System.print('onSleep');
};
myActivity.onWake = function(){
System.print('onWake');
};
myActivity.onEntry = function(){
System.print('onEntry');
};
myActivity.onExit = function(){
System.print('onExit');
myActivity.onSleep = null;
myActivity.onWake = null;
myActivity.onEntry = null;
myActivity.onExit = null;
};

}()));
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 3 made on Friday March 15, 2019 at 05:08
sebastian
Long Time Member
Joined:
Posts:
September 2003
43
Awesome, thanks! That'll help a lot!
I haven't looked into creating libraries yet, but looking at the PS dev guide, it doesn't seem to be overly complicated.

BTW: are you at liberty to reveal the meaning of the 4th bit in setDebugMask()?
My version of the dev guide covers bit 0/1/2 but not 3.
I've found an old thread where you couldn't share the info because of an NDA.

Sebastian
Post 4 made on Friday March 15, 2019 at 21:05
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,279
Basically, setDebugMask(9) which is 00001001 in binary routes the output.


If you have a TSU9600, there is a 3 pin test point solder pad inside of the DS that is a 2.2V TTL level serial port (RX, TX, GND). To use this, you need base mod and a USB adapter.

Bit 0 as you have seen routes the output to _PS_DEBUG_ panel.
Bit 3 as a bonus will route the output to the DS serial port.



Go here and download the general description doc for the Pronto Pro Development Environment

[Link: the-gordons.net]

On Barry's Base Mod doc (available in left link bar) on the Wire Up the LED page, you will these 3 solder points. TX, RX, and GND I forget which pin is which but you should not have an issue if you miswire provided you don't short 2 pads together.

These holes just so happen to fit a 3 pin molex pin header (the kind used for many PC motherboard fan connectors). I soldered one in there (placed pins on top side of the board) and then used a 3 pin molex socket and ran wires out to a stereo 1/8" jack. This just so happens to be the jack into which the USB to serial adapter from FTDI plugs.

You then use Barry's VB program to monitor the output.

Barry had the mod instructions on the site at one time, or so I thought. I bet if you email him, he will happily send along docs that will augment what I describe above.

Lyndel
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 5 made on Saturday March 16, 2019 at 04:10
sebastian
Long Time Member
Joined:
Posts:
September 2003
43
Thanks a lot for your explanation!
I've found Barry's LED mod document on his site, it shouldn't be too hard to solder in the serial pin header.
I'm not sure if I really this capability it at this time, though ;)

Sebastian
Post 6 made on Saturday March 16, 2019 at 17:48
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,279
After reading the info below, if you need the mod, contact Barry. Maybe he will do the mod for you.

I have some comments with regard to current software available. Barry's mod/code were done at a time when there was only PEP1 and there was really no way to debug your code except with the _PS_DEBUG_ panels which was basically, a royal pain.

Then, comes PEP2 with a decent debugger.

Note that if you do System.setDebugMask(9), you can see your System.print() statements in the PEP2 Emulator Console window which for most cases, effectively eliminates the need for debugging on the Pronto and gets rid of the need for the _PS_DEBUG_ solution.

The PEP2 Emulator with Jon Welfringer's TCP patch works wonders to facilitate full testing.. The only things that the PEP2 Emulator will not do are a) execute protected JavaScript (pjs files) b) Go to sleep/wake up (fire onSleep/onWake events) and c) Send IR from connected remote.

Provided you don't use the Pronto for IR but instead use RFX, with Jon's mod, you can set your config in PEP2 to used fixed-IP for all RFX units and you can run your config from your PC using the emulator.

So, if you need to test onSleep/onWake use Barry's mod. There are also some other use cases.

I used Barry's software again recently to test some things that worked in simulator. But as the simulator runs at PC speed, I needed to actual get some CPU benchmarks on the remote.

Lyndel
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 7 made on Saturday March 16, 2019 at 17:54
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,279
For those who want more history, here you go.

[Link: remotecentral.com]
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 8 made on Sunday March 17, 2019 at 06:45
sebastian
Long Time Member
Joined:
Posts:
September 2003
43
Thanks again! That definitely sounds useful - I'm just not sure how much time and effort I want to be investing in ProntoScript...

I got my TSU9800 only last year when I ditched my TSU7000 for it.
Currently all my devices are controlled via IR and I don't use any of the RFX extenders.
I once had some RF-controlled power plugs that I could control directly with the TSU7000 (European model).
Most of them were attached to lights and they got replaced with Hue lights.

I've only played a few hours with ProntoScript so far.
I managed to connect with my home automation software (home-assistant.io) and I set up an activity to control my lights through that.
Currently, I don't see many use cases that would require extensive PS coding.
Reporting the TSU's battery state back to home-assistant was a thing I wanted to try for fun.
Also, I'm thinking about controlling Kodi (kodi.tv) through its JSON API instead of IR, but that's only an idea for now.

So far I only tested small code snippets at a time and watched the debug output inside a _PS_DEBUG panel in the simulator.
I've also applied the TCP patch for it, which is an enormous improvement.
Still I'm not sure I would want to start any larger projects in PS.
Currently I'm preparing my code in a decent editor and then copy&paste it into PEP3, which can become pretty cumbersome.
Having most of the code reside in a custom library might ease things up a little, though.

As it is now, on the one hand I'm grateful for the flexibility PS allows you, but on the other hand I'd probably always check first if there's another way to solve a "problem".

Sebastian
Post 9 made on Sunday March 17, 2019 at 17:59
Barry Gordon
Founding Member
Joined:
Posts:
August 2001
2,146
The advantage of using/learning PS is manyfold. First off by learning PS you are in effect learning javaScript (JS). When I program an RPi I do all my coding in Node.js with is a variant of Javascript with specialized classes. Microsoft's Visual Studio Code runs on a Win 10 PC, and is a great editor for Node.js with a full debugging system for the code.

If you're into Apple tablets/iPhones there is a system from CommandFusion (commandfusion.com) that is in effect Pronto for the IOS and Android tablets. There is a designer package (think PEP2) and a run time system. the system supports a full Javascript Engine so you can do all of your work in JS. It handles UDP/TCP and http very nicely. My home automation system uses wall-mounted iPads for control and display, and an RPi as the central control point. the house is fully Alexa enabled.

I still use Pronto's for the TV's and the entire home theater; I want the hard buttons. The home theater has a small PC as the central control point and the 9800 talks only to it.

There is a tremendous advantage if you are a DIY Home Automation enthusiast in knowing a major programming language like Javascript or Python and being adept in it
OP | Post 10 made on Monday March 18, 2019 at 05:33
sebastian
Long Time Member
Joined:
Posts:
September 2003
43
Barry, you're absolutely right regarding the benefits of knowing one or more programming languages.
Being an IT professional myself, you're preaching to the choir here ;)

When I was looking for PS examples last year, for example, I came across an implementation of a DLNA control point app (or something along those lines) someone created "back in the day".
While this is an awesome achievement, that's about the project size where I think the Prontos today show their age.
Today you'd probably get an iPad to run these kinds of applications.
I just don't see me coding thousands of lines to run them on the TSU ;)
I will however continue to improve my PS-skills and use it in places where it makes sense (like controlling a device over the Network).

CommandFusion does sound interesting, thanks for the tip!
I think I once saw their website, but I got the impression that their hardware (i.e. server appliance) was required to make use of the apps.
If I understand you correctly, you can also have the app talk to an (open source?) implementation running on a RPi?
I'll have to look into that :)

As for the hard buttons, I'm right there with you (as is probably every Pronto user).
I wouldn't want to have a control solution purely based on touch screens.

Sebastian
Post 11 made on Monday March 18, 2019 at 15:05
Barry Gordon
Founding Member
Joined:
Posts:
August 2001
2,146
CommandFusion (CF) Has both a hardware operation and a software operation. I have never used their hardware but have extensively used their software. The two are not related but obviously will work together. Their hardware is focused on network connectivity.

The biggest issue is that they license their software on a per device level. They are completely open with regard to communications as long as it is IP based since that is all an iPad or iPhone can do. They provide their own functionality to operate without using Javascript, but Javascript gives one tremendous flexibility and power.

I use an RPi-3 as my "central controller" replacing a long time Homeseer system. The RPi handles audio (TTS) and makes all announcements needed in the house. In the house, all communications except for legacy TV and set-top boxes is over IP (UDP or TCP or http). IR and RS232 are handled by a Global Cache unit(s). The RPi opens many ports each representing a single functionality e.g. TTS; and just listens for messages.


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