Script Language

erskyTx runs on many radios and upgrade boards
ersky9x was a port of er9x for use on the sky9x board.
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB »

Down to 6 seconds, so 600 bytes per second transfer. I think I'll publish where I'm at. There is some scope for further speeding up. I currently send a packet of data and wait for a confirmation back before sending the next packet. It should be possible to overlap this and send two packets before needing to see a confirmation. The downside of that is then needing to be able to resend the first of these if there is a problem, so makes the script code more complex.

Wifi would probably be limited by the script speed as well.

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

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

Re: Script Language

Post by jhsa »

Ok, but it didn't have to be used with scripts only ;) :)

Thanks.for all.Mike..

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: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB »

Now up to 825 bytes/second, so this 3600 byte file got sent in 4.35 seconds. I've increased the packet size. I have a logic analyser on the receiving end. It does look like the BT modules are running a timeout on receiving serial data, and only sending the data on to the other module after a delay or enough data has been received. There is a delay of around 36mS after the receiving radio sends an acknowledgement before the next data packet starts appearing on the serial signal. This is "dead" time as far as data transfer is concerned, so causing some of the "slowness".

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Script Language

Post by jhsa »

Mike, could that explain the little delay I reported on the trainer a while ago??
By the way, I think 5 seconds to send a model, is quite good :) Voice files for example might take a bit longer :)

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: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB »

Just tested using a wired connection over COM2. The file transferred in less than 2 seconds, so over 1800 bytes per second. It seems the BT modules add quite a bit of latency to data transfers.

I'll post this now, and then see about improving the transfer rate over BT afterwards.

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

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

Re: Script Language

Post by MikeB »

r222C6 now posted. This includes the script additions for serial and files, and I've also included a filet.bas (for sending) and a filer.bas (for receiving).
The script language also has a bytemove() function for copying bytes from one byte array to another. strtoarray() also supports using a byte array as the string source.

To use the serial functions either set the bluetooth function to "script" on both radios or set the COM2 function to "script". The bluetooth function takes priority if you set both.

Run "filer.bas" on the radio to receive a file and filet.bas on the radio to send a file. filet.bas allows you to select from "MODELS", "VOICE\USER" and "VOICE\SYSTEM" for the location to select a file, then lets you choose a file to send.
The filename is sent to the receiving radio, and you then need to confirm you want to overwrite that file. The file is then sent!

Mike

Edit: Updated "script.pdf" on the first post.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Script Language

Post by jhsa »

Thanks Mike.. Will test now..
Question, I still didn't flash the radio or tried it, but Could the script have an option to choose between COM 2 or Bluetooth, and then enable the bluetooth momentarily while the operation is being done?
Also, instead of using two different scripts for receiving and transmitting, could the script be configured as "receive" as default, but change as soon as we start selecting the files to send?
Then, all we have to do is just to start both scripts on both radios, but there would be only one script :)

Will try it now :)

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
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Script Language

Post by jhsa »

Ok, select file to send by pressing and holding menu, it says "Polling", counts to 10 and displays "Failed" Radios are an Ar9x and the 9XT

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: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB »

I think it likely that the HC-05 gets confused if you select the BT function of "OFF" and don't have the power switching. When you select something other than "OFF", the firmware tries to re-initialise the BT module. Please try again, but simply power both radios on, with the function set to "Script", wait 10 or more seconds to give time for the link to establish, then try sending a file.
I think there will be a problem if you try to send a file that is more than about 12k long, but I have the fix for that ready!

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB »

jhsa wrote: Fri Nov 02, 2018 8:10 pmQuestion, I still didn't flash the radio or tried it, but Could the script have an option to choose between COM 2 or Bluetooth, and then enable the bluetooth momentarily while the operation is being done?
Also, instead of using two different scripts for receiving and transmitting, could the script be configured as "receive" as default, but change as soon as we start selecting the files to send?
At the moment, I don't have a way for a script to detect when the BT module has linked OK to the other BT module, and the linking looks to take up to 10 seconds, so only enabling the module when required is unlikely to work very well.

It may well be possible to merge the two scripts into one. Clearly, such a script would be larger. I'm testing on a SKY board, which has the smallest amount of RAM available for scripts, so I wasn't sure a combined script would fit.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Script Language

Post by jhsa »

Ok, progress. waiting the 10 seconds made the radios start the sending/receiving procedure, but, after accepting the file on the other radio, the sending radio display "sending", and then "Failed". The receiving radio keeps displaying "Receiving"

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
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Script Language

Post by jhsa »

Funny, I am able to send files from the ar9x to the 9XT, but not the other way round. 9XT is configured as Master, and the Ar9x is configured as Slave, don't know if this is relevant..

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
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Script Language

Post by jhsa »

Both configured as SLAVE, it doesn't work either way.
9XT MASTER and Ar9x SLAVE, I can send from Ar9x to 9XT but not the other way round.
9XT SLAVE and Ar9x MASTER, I can send from Ar9x to 9XT. From 9XT to Ar9x, it starts sending but then it fails.. Sometimes I can see the bar start moving. This is the same model it received from the other radio. I have seen it go as far as half of the bar a couple times.

While trying to load the script on the Ar9x board I have seen a reboot. The error is "Watchdog 2"
I hope this helps..
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
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB »

I just tested with my 9XT and SKY board. The 9XT as master doesn't seem to link to the SKY radio. I swapped them round (SKY master, (XT slave) and then I've sent a file from the 9XT to the SKY radio.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB »

All my testing has been done without any RF modules plugged in. If possible, please try with the AR9X RF modules OFF.
I don't have a BT module in my AR9X radios, but the SKY board should be the same.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Script Language

Post by jhsa »

Ok, turned RF Modules OFF on both radios (selected another model on the Ar9x, and turned RF off on the 9XT current model), and I was able to send a file from the 9XT to the Ar9x, and immediately the other way round.
My question is, why is the RF modules being ON causing the problem.. It seems unrelated?? at least to me.

João

EDIT: would it be possible to be able to use the center button to select scripts and its options? ;) It is really annoying when I press the button and I am out of the scripts menu :)
Thanks
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: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB »

The problem is interrupt overload. Each byte of serial data is causes an interrupt. When several interrupts occur at the same time they are processed according to their set priority. Interrupts are also needed at times to handle sending the control data to the module(s) (PPM, XJT, Multi etc.)
Serial data includes telemetry data from the module.
What it seems is happening is the interrupt for the serial data from the BT module is low enough in the priority list (I've already raised its priority) that bytes are being missed, causing the problem you see. The BT data is arriving every 83uS (115200 baud).
As an experiment, you could try changing the BT baudrate to 57600 (in the Radio SETUP|General menu), and enable the modules.

I'm looking at using DMA instead of interrupts for the received BT data. I used to use DMA on COM1, but had to change to using interrupts to handle FrSky SPort telemetry polling, so I have some code available to remind me how to use DMA. I'll check to see if DMA could also be used for COM2 (DMA = Direct Memory Access where hardware reads data from the UART and puts it in memory without needing an interrupt).

A short press of the encoder button should select a script to run, and also a file in the file list. For selecting the directory in the script, try changing the line:
if Event = EVT_MENU_BREAK
to:
if Event = EVT_MENU_BREAK | Event = EVT_BTN_BREAK

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Script Language

Post by jhsa »

Good morning Mike. So, you will try to use DMA on COM2 and COM3? This is what I understood.
if Event = EVT_MENU_BREAK
to:
if Event = EVT_MENU_BREAK | Event = EVT_BTN_BREAK
Where should I change this? In the script? Both?

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
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Script Language

Post by jhsa »

MikeB wrote: Sat Nov 03, 2018 10:03 am
As an experiment, you could try changing the BT baudrate to 57600 (in the Radio SETUP|General menu), and enable the modules.

Just tried this, and as you said, all worked fine with internal modules on both radios turned ON. I tried changing the master and slave settings on them (always one as master while the other config as slave), and it also worked.

perhaps an alternative to using DMA, and if it could be done, would be changing the BT /COM2 BaudRate while using file transfer?? I had one model transfer really really quick, less than a second. I wonder if it got corrupted on one of the failed transfers?? Need to check this..

Also, what about the file transfer as an APP instead of script?

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
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Script Language

Post by jhsa »

Yep, I think that model got corrupted, basically it has only one mix on ch01 and the model name. all the other settings seem to have been reset. It was an example model I had on the card and it did count from 0 to 10. So it used GVARs. The GVAR adjusters are all reset. the model took about a second to transfer, so I guess this explains why :)

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: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB »

I've posted r222c7. This only has a change for Atmel processor radios to prevent BT data getting "lost" due to interrupt overload.
I've also fixed a bug in filer.bas and filet.bas that caused a problem when transferring files larger than 12K. I've removed filer.bas and filet.bas from the r222c6 zip file.

MIke
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Script Language

Post by jhsa »

Thanks Mike.. I have tested this (transferring models only so far), and it works well. Killer feature in ersky9x :D
Radios are charging. Will resume testing later :)
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: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB »

A small upgrade to the script language will be in r222c9. Where you have a string (e.g. "A string"), you will be able to incude an array subscript, e.g. "A string"[2]. In this example, you get the string "string", that is the original string, but starting 2 characters in.

Where this night be useful is where you wish to display different strings at the same position on the display.
Currently you may have something like:
if condition1
drawtext( x, y, "String1")
elseif condition2
drawtext( x, y, "String2")
else
drawtext( x, y, "String3")
end

This could be replaced by:
if condition1
index = 0
elseif condition2
index = 8
else
index = 16
end
drawtext( x, y, "String1\0String2\0String3"[index])

This is particularly useful if the x and y values are calculations, it saves quite a lot of script code space.

Comments may no also be indicated by // as well as by rem.

I've also just noticed that blank lines still have their line number placed in the loaded code (rem statements don't). I have a fix so that blank lines don't have their line number included, so making the the loaded code slightly smaller.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Script Language

Post by jhsa »

If you keep shrinking the script code, one day you will make it small enough for the 9x stock board ;) :mrgreen:

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
rcfish
Posts: 62
Joined: Tue Jan 10, 2017 8:11 pm
Country: Germany

Re: Script Language

Post by rcfish »

Hello Mike
I just discovered that "sysstrtoarray" doesn't work on testversions 222c6 -222c8.
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB »

I have the fix, it will be in the next test version.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Script Language

Post by MikeB »

rcfish wrote: Thu Nov 08, 2018 6:45 pm I just discovered that "sysstrtoarray" doesn't work on testversions 222c6 -222c8.
R222 c9 now posted with this fixed.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
rcfish
Posts: 62
Joined: Tue Jan 10, 2017 8:11 pm
Country: Germany

Re: Script Language

Post by rcfish »

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

Re: Script Language

Post by MikeB »

A couple of additions/changes to the language that will be in the next test version.
1. You may use "break" in a while loop to jump out immediately.
2. The function sporttelemetrysend() will accept either a variable or a byte array for the 4-bytes of data.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
AlessB
Posts: 31
Joined: Wed Mar 01, 2017 9:09 am
Country: Ukraine

Re: Script Language

Post by AlessB »

Mike thanks for your posted new manual and interpreter.
I don't understand were wrong in my script.

Code: Select all

 rssi=getvalue ( "RSSI" )
if  rssi =0
resettelemetry (4)
end
stop
Error 103 at line 3

Post Reply

Return to “erskyTx (was ersky9x)”