Script Language

erskyTx runs on many radios and upgrade boards
ersky9x was a port of er9x for use on the sky9x board.
cutdact
Posts: 21
Joined: Tue Oct 04, 2016 7:28 am
Country: Finland

Re: Script Language

Post by cutdact » Thu Sep 07, 2017 6:33 pm

Thank you for the example.

I've got a XSR reveiver and i would like to attempt receiving the PID values as a start. After some research it looks like i need to do some modification to the receiver in order to be able to do this. How would i go about using sportTelemetryReceive?

In Lua i think it looks like this:

local sensorId, frameId, dataId, value = sportTelemetryPop()

I'm fully aware this is way over my coding knowledge, but maybe i'll learn :D


User avatar
MikeB
9x Developer
Posts: 17024
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB » Thu Sep 07, 2017 6:40 pm

result = sportTelemetryReceive( sensorId, frameId, dataId, value )
where:
sensorId, frameId, dataId, value
are variables. The code will fill these in with the received values, and the function returns 1 if a frame was received OK and 0 if not.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

cutdact
Posts: 21
Joined: Tue Oct 04, 2016 7:28 am
Country: Finland

Re: Script Language

Post by cutdact » Mon Sep 11, 2017 8:47 am

Getting syntax error when run and i can't figure out what i'm doing wrong...

User avatar
MikeB
9x Developer
Posts: 17024
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB » Mon Sep 11, 2017 9:28 am

Do you see a line number for the syntax error? If so, what is the statement on the line?
If not, please post your script in full and I'll have a look.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

cutdact
Posts: 21
Joined: Tue Oct 04, 2016 7:28 am
Country: Finland

Re: Script Language

Post by cutdact » Mon Sep 11, 2017 11:40 am

I do see a line number, it's

if Event = EVT_MENU_BREAK
result = sportTelemetryReceive( sensorId, frameId, dataId, value ) syntax error 103
end


User avatar
MikeB
9x Developer
Posts: 17024
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB » Mon Sep 11, 2017 1:39 pm

My mistake, I haven't got the processing for "sportTelemetryReceive" called. I thought I had tested it, but I may have got confused from when I was testing LUA, when it was working.
I also have the wrong error being reported, It looks like the correct error is being overwritten before it gets reported.

I'll post a "e4" test version shortly.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

cutdact
Posts: 21
Joined: Tue Oct 04, 2016 7:28 am
Country: Finland

Re: Script Language

Post by cutdact » Mon Sep 11, 2017 1:53 pm

Alright!

Thanks Mike!

User avatar
MikeB
9x Developer
Posts: 17024
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB » Mon Sep 11, 2017 2:46 pm

OK, I've posted a new test version ("e5"). I haven't had time to test the sport receiving in the script, but it is new processed.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

cutdact
Posts: 21
Joined: Tue Oct 04, 2016 7:28 am
Country: Finland

Re: Script Language

Post by cutdact » Mon Sep 11, 2017 5:03 pm

Thank you!

I ran one script without error so i think it works, i just need to modify my receiver to uninvert telemetry..

I also played around with if functions but can't get the else statement to run, getting syntax error 3.

BTW
What's the line on page 8/15 SCRIPT at the bottom for?

Martin

cutdact
Posts: 21
Joined: Tue Oct 04, 2016 7:28 am
Country: Finland

Re: Script Language

Post by cutdact » Mon Sep 11, 2017 7:54 pm

Alright so i got the menu working, i'll post the code if anyone is interested. One thing that would be nice to be able to do is to use both BLINK and PREC2 on the same "drawnumber", is this possible?

Code: Select all


array myPID[10]


z = 3*x-y


drawtext( 0, 0, "KISS Setup: PIDs", INVERS )
drawtext( 111, 0, "1/5", 0 )

drawtext( 50, 14, "P", 0 )
drawtext( 78, 14, "I", 0 )
drawtext( 106, 14, "D", 0 )

drawtext( 4, 25, "Roll", 0 )
drawtext( 4, 36, "Pitch", 0 )
drawtext( 4, 47, "Yaw", 0 )

drawnumber( 55, 25, myPID[1], rP )
drawnumber( 83, 25, myPID[2], rI )
drawnumber( 111, 25, myPID[3], rD )

drawnumber( 55, 36, myPID[4], pP )
drawnumber( 83, 36, myPID[5], pI )
drawnumber( 111, 36, myPID[6], pD )

drawnumber( 55, 47, myPID[7], yP )
drawnumber( 83, 47, myPID[8], yI )
drawnumber( 111, 47, myPID[9], yD )

if z = 1 then rP = BLINK 
if z # 1 then rP = 0

if z = 2 then rI = BLINK 
if z # 2 then rI = 0

if z = 3 then rD = BLINK 
if z # 3 then rD = 0

if z = 4 then pP = BLINK 
if z # 4 then pP = 0

if z = 5 then pI = BLINK 
if z # 5 then pI = 0

if z = 6 then pD = BLINK 
if z # 6 then pD = 0

if z = 7 then yP = BLINK 
if z # 7 then yP = 0

if z = 8 then yI = BLINK 
if z # 8 then yI = 0

if z = 9 then yD = BLINK 
if z # 9 then yD = 0




if Event = EVT_LEFT_FIRST then y += 1
if Event = EVT_RIGHT_FIRST then y -= 1


if x < 1 then x = 1
if x = 4 then x = 1


if y > 2 then y = 2
if y < 0 then y = 0

if Event = EVT_MENU_BREAK then x += 1



if Event = EVT_DOWN_FIRST then myPID[z] -= 1
if Event = EVT_UP_FIRST then myPID[z] += 1

if Event = EVT_EXIT_BREAK then goto done
if Event = EVT_BTN_BREAK then goto done
stop
done:
finish



User avatar
MikeB
9x Developer
Posts: 17024
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB » Mon Sep 11, 2017 9:46 pm

Where you have:
if z = 4 then pP = BLINK
if z # 4 then pP = 0
the following should work:
if z = 4
pP = BLINK
else
pP = 0
end

As I have the language at present, if you have a "then" on an "if" statement line, it means carry out the code that follows the "then" after which the "if" statement is complete, no "else" or "elseif" follows.
An "if" statement without a "then", starts a sequence of statements (1 or more), and you may have an "else" or "elseif".

The bottom line on the "SCRIPT" menu is debug information for me to check things are working as I expect. I'll remove it now!

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

User avatar
MikeB
9x Developer
Posts: 17024
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB » Tue Sep 12, 2017 1:29 pm

cutdact wrote:
Mon Sep 11, 2017 7:54 pm
One thing that would be nice to be able to do is to use both BLINK and PREC2 on the same "drawnumber", is this possible?
Yes, drawnumber( x, y, 237, PREC2+BLINK) will display 2.37 with reverse video blinking.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

tsenecal
Posts: 45
Joined: Wed Mar 22, 2017 8:32 pm
Country: United States

Re: Script Language

Post by tsenecal » Fri Sep 15, 2017 10:35 pm

does one have to have an upgraded ar9x board with the newer CPU to use the scripting language? or will simple scripts still fit in the available ram of a standard/stock ar9x board?

User avatar
MikeB
9x Developer
Posts: 17024
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB » Fri Sep 15, 2017 11:12 pm

No you don't need to have an upgraded CPU, scripts work OK on the standard CPU. This is why I've written this language!
I'm just writing/testing a script that does the S6R/S8R configuration. The script file is less than 9K, I'll need to check how much RAM it is actually using when it runs.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

User avatar
jhsa
Posts: 19321
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Script Language

Post by jhsa » Sat Sep 16, 2017 1:21 am

Mike, that configuration script is perhaps one of the most RAM hungry we will ever use, right?
If that runs OK, most of the others will?
For example, if I wanted to make a script for a menu for the music player. would it be lighter or heavier than the configuration one you are writing?
This is just an example, I don't even know if the scripts can access the music player's commands, like selecting and album, or "Loop", or "List/File", etc.. It would be nice to have a menu though as the music player is still in the debug menu :) ;)

Thanks

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
MikeB
9x Developer
Posts: 17024
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB » Sat Sep 16, 2017 9:48 am

I'm not sure if that script is one of the largest or not. It may also become smaller if I add some more features to the language!
At present, a script can't handle accessing a list of files, or the "music" settings. I'm thinking about how a script can access things like that safely.
A script can use "setswitch" to set a logical switch on or off, so it could, at least, control the music operation if such a logical switch was assigned to a music control function.

While the screen is still in the "Statistics" area, you can get to it from the "Music" menu in the model setup (choose "Configure").

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

User avatar
jhsa
Posts: 19321
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Script Language

Post by jhsa » Sat Sep 16, 2017 10:46 am

MikeB wrote:
Sat Sep 16, 2017 9:48 am
A script can use "setswitch" to set a logical switch on or off, so it could, at least, control the music operation if such a logical switch was assigned to a music control function.
But for setting a switch to control the music we don't need a script :) we can do it from the model settings / music menu, and we can use logical switches too..
Scripts are good for real time configuration and new personalized menus. All the rest I believe the radio alone can already do :)
That is why I mentioned the music menu as an example. I personally would like to just use the directional keys to enter the player menu, just like we scroll through the other mainscreens.. But this one could be edited, and we could select start stop, pause etc. from there. Not all radios have the same amount of push buttons as my radios :) And we could also see the name of the track playing..
But this doesn't add any real functionality to it.. It is just a visual enhancement.. :)
While the screen is still in the "Statistics" area, you can get to it from the "Music" menu in the model setup (choose "Configure").
You are full of surprises Mike :) I haven't seen that before.. Yes, that makes it much more easier to configure the player..
Thank You

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

mrozilla
Posts: 60
Joined: Sat Nov 14, 2015 9:59 pm
Country: -

Re: Script Language

Post by mrozilla » Sat Sep 16, 2017 2:58 pm

@MikeB I threw scripts on 9XR Pro and t.bas works and can be exited with EXIT button, while tel0.bas script shows only "Telemetry Script" and number 11.0 and can not be exited with any button, EXIT button also does not work, You can only switch off and switch on the unit by pressing the ON / OFF button.

User avatar
MikeB
9x Developer
Posts: 17024
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB » Sat Sep 16, 2017 4:47 pm

Are you running tel0.bas standalone or as a "telemetry script" on a custom telemetry page?
The 11.0 is your Tx battery voltage.
Does EXIT LONG stop the script?

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

mrozilla
Posts: 60
Joined: Sat Nov 14, 2015 9:59 pm
Country: -

Re: Script Language

Post by mrozilla » Sat Sep 16, 2017 5:51 pm

I run it by "Run Script" In the main menu the same as t.bas. Unfortunately, the long press EXIT does nothing in this script. The t.bas works properly, turns it off and returns to the previous window, while in tel0.bas nothing happens, it does not react to any button although in the background you hear eg press the trimmers but the display does not change.

User avatar
MikeB
9x Developer
Posts: 17024
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB » Sat Sep 16, 2017 8:21 pm

tel0.bas is intended as a telemetry script, configured to run in a custom telemetry screen.
I'll look into why EXIT LONG doesn't terminate it.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

mrozilla
Posts: 60
Joined: Sat Nov 14, 2015 9:59 pm
Country: -

Re: Script Language

Post by mrozilla » Sun Sep 17, 2017 6:54 am

Which is a custom telemetry screen? I run it on the telemetry screen where I have RX and TX bars and BEC voltage and the package voltage but here the script looks the same as in the main menu and it can not be turned off.

User avatar
MikeB
9x Developer
Posts: 17024
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB » Sun Sep 17, 2017 9:04 am

You configure a custom telemetry screen in the telemetry menu (popup option "Custom"). Here you set the filename after changing the type to "script".
The custom screen will then display the output of the script. It is assumed you don't want to terminate this script.
You should be able to move left and right out of that screen.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

mrozilla
Posts: 60
Joined: Sat Nov 14, 2015 9:59 pm
Country: -

Re: Script Language

Post by mrozilla » Sun Sep 17, 2017 10:20 am

I changed the value to script, gave name tel0, and unfortunately shows "SCRIPT ERROR".
I threw tel0 into the "scripts / telemetry" folder and now, instead of "SCRIPT ERROR", the same information that I wrote earlier, "Telemetry Script" and the tension of the device package appear. In this situation, I can scroll left / right telemetry windows. Should not this script display more information?

I have a second question, I noticed that without using the scripts and having a standard telemetry window I have one window configured correctly A1, A2, TX and RX and the bottom bars, but after scrolling to the right I have a blank window with only stripes at the bottom, Remove this second (Custom Display 2) window?
Last edited by mrozilla on Sun Sep 17, 2017 10:48 am, edited 1 time in total.

User avatar
MikeB
9x Developer
Posts: 17024
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB » Sun Sep 17, 2017 10:48 am

Does it still do that if you power off and on. I did have a problem at one time where it didn't start running until you cycled power.
Also, as a "TELEMETRY" script, it needs to be in the directory /SCRIPTS/TELEMETRY, not just /SCRIPT.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

User avatar
MikeB
9x Developer
Posts: 17024
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB » Mon Sep 18, 2017 3:14 pm

I now have the S6R/S8R script working. I had to make a few changes to ersky9x script operation to get it fully working, while also limiting how much processor power is allocated to script processing. I also found a few minor bugs in script operation.
I'll post updated test versions when I've tested on several Txs, together with the script.
For information:
The script text is 9494 bytes long.
When running, it uses 4484 bytes of RAM.
To load the script uses 5332 bytes, as a symbol table needs to be built for this, but the table is not needed when running, and is overlaid by a "script control structure" and the script's variables.
This script language doesn't use dynamic RAM allocation when running, so these numbers won't change when the script is running.
The symbol table could be smaller, if the variable and label names were shorter.
I've been testing on a 9XR-PRO, with 16000 bytes of RAM allocated to scripts.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

User avatar
jhsa
Posts: 19321
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Script Language

Post by jhsa » Mon Sep 18, 2017 4:34 pm

Nice.. I guess that with LUA this would be impossible on the PRO?? :)

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
MikeB
9x Developer
Posts: 17024
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB » Mon Sep 18, 2017 6:20 pm

Quite possibly, although I'm not going to build with LUA again and try it to find out!

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

User avatar
jhsa
Posts: 19321
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Script Language

Post by jhsa » Mon Sep 18, 2017 10:40 pm

Of course not.. Your implementation seems to be much better, hence my comment above :) :D


João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
MikeB
9x Developer
Posts: 17024
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB » Mon Sep 18, 2017 11:04 pm

I've posted "e6" test version. This has some improvements to how scripts are handled.
I've also included "S6R.bas", a script for reading/writing configuration data to S6R and S8R receivers. It may help anyone trying to write a script to see how some things work.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!


Post Reply

Return to “erskyTx (was ersky9x)”