Page 9 of 12

Re: Script Language

Posted: Wed Oct 10, 2018 10:20 am
by vodkabears
Hello Mike. Is there any way to debug scripts? Mine just stops working right after start, it will be hard to find a problem.

Re: Script Language

Posted: Wed Oct 10, 2018 4:10 pm
by MikeB
What Tx are you using?
Is your script very large?
I'm (currently) allocating 12k bytes of RAM for scripts (except for the SKY board that only has 8k). I'm wondering if your script is too large to fit.

Mike

Re: Script Language

Posted: Thu Oct 11, 2018 1:17 pm
by vodkabears
9XR-PRO. Yes, about 1k lines. 12 kB might be too few for it.

Re: Script Language

Posted: Thu Oct 11, 2018 3:53 pm
by MikeB
I will increase the space available on the 'PRO, although if the script is too large, you should get an error 10 reported.

I did originally have a test setup I used on my computer, running the script language within QTCreator. If you have QTCreator I could see about making this available.

Mike

Re: Script Language

Posted: Thu Oct 11, 2018 5:24 pm
by rcfish
MikeB wrote: Thu Oct 11, 2018 3:53 pm I did originally have a test setup I used on my computer, running the script language within QTCreator.
Does that mean you can run the scripts without having to upload them to the TX? This yould be great I think.

Re: Script Language

Posted: Thu Oct 11, 2018 11:34 pm
by MikeB
That test setup was really for me to test the code that handles the script, so doesn't have a script display output.
It may take a bit of time but I should be able to get a display output, I have some hooks in for it that seem to work. I've just got "drawtext" displaying something.
I'll probably need to add some buttons (Menu, Exit etc,) to the display.
How much of any script can be simulated, I'm not sure, things like getting telemetry values won't work.

What I also do have working is the same syntax check as the radio uses, so this should, at least, check the syntax. It does use the same source code file as the radio.

Give me a few days to see if I can knock this into shape.

Mike

Re: Script Language

Posted: Thu Oct 11, 2018 11:42 pm
by jhsa
what about if the scripts could be simulated in Eepskye?

João

Re: Script Language

Posted: Fri Oct 12, 2018 8:56 am
by MikeB
Later maybe, but much easier to develop the feature using a specific application.

Mike

Re: Script Language

Posted: Sat Oct 13, 2018 11:18 pm
by MikeB
I'm making good progress on a PC program to test scripts. I have it running with 6 buttons working and a simulated display (128x64).
I have text, numbers and graphics displaying, complete with the popup working.
I need to add a file select dialog, it is currently using a hard coded path to a script to run.

Mike

Re: Script Language

Posted: Sun Oct 14, 2018 3:42 pm
by MikeB
I've posted, on the first post of this thread, a first version of a PC (windows only so far) program that runs scripts.
Copy "interpreter.exe" into the directory in which you have installed eepe/eepskye (it needs the QT dll files), then run it.
Click on the "File" button to select your script file, then click on the "Run" button to run it. The Menu, Exit, Left, Right, Up and Down buttons should operate as though you are using them on the radio. The "Abort" button stops a running script.
Remember that this cannot simulate all the functions, although it should check the runtime operation without performing those functions.

Mike

Re: Script Language

Posted: Sun Oct 14, 2018 4:37 pm
by rcfish
That‘s really cool . Thank you

Re: Script Language

Posted: Sun Oct 14, 2018 5:14 pm
by jhsa
Thanks Mike..

João

Re: Script Language

Posted: Mon Oct 22, 2018 11:37 pm
by MikeB
Just adding a new BT function "Script", and two new functions to scripts "btsend" and "btreceive". This should allow scripts to send and receive data over bluetooth.
I have just tested a script that sends a single character 'A' once per second, and received that over bluetooth in a terminal emulator on my PC, so that much seems to work.

Mike

Re: Script Language

Posted: Tue Oct 23, 2018 12:12 am
by jhsa
Would it be for example possible to mimic the radio screen over bluetooth on an android device?

João

Re: Script Language

Posted: Wed Oct 24, 2018 8:14 pm
by MikeB
Possibly if someone writes an "app" for android.

I have now tested serial data both ways, so this addition looks to be working.

Mike

Re: Script Language

Posted: Wed Oct 24, 2018 8:28 pm
by jhsa
MikeB wrote: Wed Oct 24, 2018 8:14 pm Possibly if someone writes an "app" for android.

Mike
That would be wonderful.. Anyone?? :o :o :mrgreen: :mrgreen: :mrgreen: ;) ;)

We could build our own radios without LCD and use the pins for something else :)
Our radio's display could be any size and even be kept in our pocket until we need it.
Make it wireless over wifi and the possibilities multiply :)

João

Re: Script Language

Posted: Thu Oct 25, 2018 8:15 pm
by tsenecal
jhsa wrote: Wed Oct 24, 2018 8:28 pm
MikeB wrote: Wed Oct 24, 2018 8:14 pm Possibly if someone writes an "app" for android.

Mike
That would be wonderful.. Anyone?? :o :o :mrgreen: :mrgreen: :mrgreen: ;) ;)

We could build our own radios without LCD and use the pins for something else :)
Our radio's display could be any size and even be kept in our pocket until we need it.
Make it wireless over wifi and the possibilities multiply :)

João

please, for the love of god, NO.

Re: Script Language

Posted: Thu Oct 25, 2018 9:26 pm
by jhsa
Why not? You shouldn't even need the LCD when flying. We shouldn't take our eyes away from the model. That is why we have voice alarms, so we don't have to look at the screen when flying the models :)

I would like to have eepskye on android for example.. Very useful when at the field :)

João

Re: Script Language

Posted: Thu Oct 25, 2018 10:18 pm
by tsenecal
jhsa wrote: Thu Oct 25, 2018 9:26 pm Why not? You shouldn't even need the LCD when flying. We shouldn't take our eyes away from the model. That is why we have voice alarms, so we don't have to look at the screen when flying the models :)

I would like to have eepskye on android for example.. Very useful when at the field :)

João
if all you are trying to do is get eepskye on a tablet at the field, android is not the way to do it... you can find 8" and 10" windows tablets for less than $200, get all the power of having a real OS, and you won't be stuck trying to answer your phone while connected to your transmitter...

Re: Script Language

Posted: Thu Oct 25, 2018 10:52 pm
by jhsa
Android is much more widely spread as OS as far as I know.. :) And I don't like windows anyway.. It likes crashing too much :mrgreen: :mrgreen:

Also, my point is to not take a huge tablet to the field, but to be able to use my smartphone which is much smaller. If I wanted a bigger screen, I would just take my laptop or notebook anyway, which I don't.. But i always take my android phone with me, and so do most of the people probably :) ;)

João

Re: Script Language

Posted: Fri Oct 26, 2018 4:23 pm
by MikeB
I've extended the COM2 function to include "Script" as well, and renamed the "btsend" and "btreceive" functions to "serialsend" and "serialreceive". This allows scripts to send and receive serial data over either bluetooth or COM2.

For "standalone" scripts, I'm also adding some file access. Using files needs some RAM for each file. Currently, I'm re-using the same file structure as that used to load scripts. This means you may only have a single file, and, to avoid conflicts, you may only access it from a standalone script as no other scripts are running or loading while a standalone script is running. Once this is all working, I may see if I can extend this to other script types, and/or allow more than one file open at a time (not sure what for though!).

I have most of this working, but it needs more testing.
Due to the way I handle selecting files, I'm providing the following functions:

directory( path, extension )
This sets up the list of files from the specified directory path with the given extension.

fileselect( filepath, size )
This allows you to select a file from the list created using the directory() function. If you select a file, then the size of the file is placed in the variable you supply (called size here).

fopen( filename, mode )
This opens the file with the (full path) of filename. mode is 0 for read and 1 for write. Opening a file for write will clear any existing data in an existing file.

fread( length, buffer, number_read )
Reads length bytes from the open file, storing them in buffer, and setting number_read to the number of bytes actually read.

fwrite( length, buffer, number_written )
Writes length bytes from buffer to the open file, and sets number_written to the number of bytes actually written.

fclose()
Closes an open file.

With these, I think it should be possible to transmfer a file from one radio to another either over bluetooth or a serial connection.

Mike

Re: Script Language

Posted: Fri Oct 26, 2018 4:49 pm
by jhsa
wow, so we could have a script, or an app to transfer files? would we need this Script on both radios in order to send / receive it?
Also, would we have to write a new script with a new file path and name to send a different file? :o or could we just select it from a list? This would be wonderful. :)

Thanks

João

Re: Script Language

Posted: Fri Oct 26, 2018 5:51 pm
by MikeB
A script on both radios.
directory() and fileselect() let you choose a file from a list.

Mike

Re: Script Language

Posted: Fri Oct 26, 2018 10:15 pm
by jhsa
Thanks Mike.. would love to try that :)

João

Re: Script Language

Posted: Wed Oct 31, 2018 11:03 pm
by MikeB
I have just managed to send a (model) file from my SKY board radio to my QX7 over bluetooth.
It does, currently, take a relatively long time, and I can see some retries occuring where there are some transmission errors (e.g. lost bytes), but the file did get transferred correctly.
I need to clean up the scripts (e.g. removing debug from the display), and probably speed it up a bit, before I 'publish' the scripts. I will also need to post updates firmware files that support the required functions.

Mike

Re: Script Language

Posted: Wed Oct 31, 2018 11:57 pm
by jhsa
Thanks Mike.. How long was a long time?? ;) :)

João

Re: Script Language

Posted: Thu Nov 01, 2018 12:13 am
by MikeB
I have it sending about 240 bytes per second, so a 3600 byte file took 15 seconds. I'm not sure why it is this slow, I think it should be at least 5 time faster.

Mike

Re: Script Language

Posted: Thu Nov 01, 2018 12:48 am
by jhsa
Do you have two HC-05?? Could it be the BT modules, or shouldn't it make a difference??

Thanks

João

Re: Script Language

Posted: Thu Nov 01, 2018 10:59 am
by MikeB
Currently sending from SKY board to QX7 with HC-05 and 'PRO with HC-06. The 'PRO/HC-06 was very bad. I've just raised the interrupt priority for the serial receive data from the BT module on the 'PRO and that is now working much better, the file transferred in 10 seconds, but still had some retries.
I need to investigate if I'm still missing serial data.
Raising the interrupt level on the SKY board has enabled sending the file, to the 'PRO, with no retries, so I can look into speeding this up more.

Mike

Re: Script Language

Posted: Thu Nov 01, 2018 11:37 am
by jhsa
This is great Mike, thank you.. I wonder how faster it would be with wifi, now that you have found a way to turn the modules off when not in use, avoiding draining the battery ;)

João