Torque

Forums

Forums

Guest  

Show or hide header
Welcome Guest, posting in this forum require registration.




Torque » Torque OBD ECU Scanner » Torque Discussion / Ideas » Scripting support

Pages: [1] 2
Author Topic: Scripting support
piemmm
Administrator
Posts: 6629
Post Scripting support
on: January 2, 2022 (GMT)

Hi!

It’s time to look into scripting!

Could those that are interested/requested this feature give me ideas of the things they would like the scripts to be able to do? (A use-case would be ideal!)

Capp777
Member
Posts: 2994
Post Re: Scripting support
on: January 3, 2022 (GMT)

Hi Piemmm,

I remember suggesting a .txt batch file
type capability where a text file contains
the OBD commands, a message box for user
instructions, pause or wait then more
commands.

The message box function provides specific
instructions to the user such as running
a test push this button/pedal, turn steering
wheel, etc.

Clear as mud right?

KOEO/KOER for instance.

Drive cycle instructions, etc.

— Sample .txt file —

Msgbox(“Cold Start below 120°F”, OK, CANCEL)

Msgbox(“Warm-up at idle”, OK, CANCEL)

Wait(8, m)

Beep()

Msgbox(“Accelerate to 55 mph at 1/2 throttle”, OK, CANCEL)

Msgbox(“Steady cruise at 55 mph for 3 minutes”, OK, CANCEL)

Wait(3, m)

Beep()

Msgbox(“Coast down to 20 mph without brake or clutch”, OK, CANCEL)

Next instruction, etc.

— — — —

OK to execute next step.

CANCEL to exit task.

Edited.

piemmm
Administrator
Posts: 6629
Post Re: Scripting support
on: January 6, 2022 (GMT)

OK – Some of this might make it’s way into the pushbutton to begin with then, as well as the equation parser to begin with.

Once I’ve finished with this version I’ll add it to the next beta update (it’s just in ‘bugfix mode’ at the moment for the next couple of updates before I work on the next ‘feature update’ where new stuff gets added)

piemmm
Administrator
Posts: 6629
Post Re: Scripting support
on: January 7, 2022 (GMT)

Hi!

Ok, this will probably start appearing sometime near end of next week in pushbutton to start with, then the equation parser later on. It’ll be in beta for a while so I have time to get things right. Right now I’m finalising .254 which is looking like a good release

(But we’ll leave VisualBasic at the door….)

piemmm
Administrator
Posts: 6629
Post Re: Scripting support
on: January 14, 2022 (GMT)

This is mostly done now and is configurable via the pushbutton in the usual way – I need to write some documentation on the wiki before I release the beta

A side effect is that there are also now ‘core’ scripts in the main part of the app as well (accessible through the settings in a ‘Manage Scripts’ pane similar to the ‘Manage extra PIDs/sensors’ pane) – this will also be making it’s way into the beta

piemmm
Administrator
Posts: 6629
Post Re: Scripting support
on: January 18, 2022 (GMT)

Hi!

I’ve started documenting this now:

https://wiki.torque-bhp.com/view/Scripting

to get an idea of how it’s going to look – look at the pushbutton class as it at least contains a very, very quick example

You get modal/blocking dialogs too

Capp777
Member
Posts: 2994
Post Re: Scripting support
on: January 21, 2022 (GMT)

Tried using your example script but unable
to save.

/storage/emulated/0/Andriod/data/

org.prowl torque/files/buttonScripts:
open failed:

EISDIR (is a directory)

Tab S6 Lite
SM-P610
Android 11

piemmm
Administrator
Posts: 6629
Post Re: Scripting support
on: January 21, 2022 (GMT)

Hi!

That should be fixed in 1.12.4 (the latest update today) as the editor had a few issues – I’d been editing on the computer so didn’t see these but they should all be sorted out now

Capp777
Member
Posts: 2994
Post Re: Scripting support
on: January 24, 2022 (GMT)

Could you please include a working example
of a dialog popup in the pushbutton default
script? I trying to teach myself Java programming
as I go, but am struggling.

Noticed I had to leave dashboard then back again
to see more detailed error message.

Thanks for adding the scripting features.

Can’t wait to see other’s working scripts.

piemmm
Administrator
Posts: 6629
Post Re: Scripting support
on: January 25, 2022 (GMT)

Hi!

It’s “not quite java” but close – the OO approach (when coming from structured programming) does take a little time to get your head around it, but it is very much worth the effort! :) there’s more info here: https://commons.apache.org/proper/commons-jexl/reference/syntax.html

Also there’s now a pushbutton demo at the bottom of: https://wiki.torque-bhp.com/view/Scripting

You’ll want 1.12.10 (out in an hour or so) before it’ll work properly though as I discovered a small issue on some devices

Capp777
Member
Posts: 2994
Post Re: Scripting support
on: January 29, 2022 (GMT)

Thanks Ian for including the working example
of the blocking dialog popup.

Next question is it possible to have popup beep
to get the users attention when it appears? or
is there a function for making the beep?

Is there a way to change popup location of the
dashboard?

While the script is working, still have to exit
dashboard, then go back to see changes from edits.

piemmm
Administrator
Posts: 6629
Post Re: Scripting support
on: January 29, 2022 (GMT)

Hi!

There’s no beep function, yet…

I’ll see if I can get it into the next update or so – it would be sooner but I’m looking into something quite complicated at the moment and it’s taking a bit of time to get through

I’ll probably create a ‘Sound’ class capable of playing beeps or a sequence of beeps at varying pitches once the other stuff is completed

Capp777
Member
Posts: 2994
Post Re: Scripting support
on: January 30, 2022 (GMT)

I go from a working script to …

Script terminated abnormally run:1@21:1
Tokenization error in “

Script failed to load correctly – check the script

I can’t seem to find the issue. All the popups that
once were working are not now.

Does @21:1 mean problem is located in line 21?
character 1?

It would also help to show the error message longer for
recording purpose.

TIA. Still learning!

piemmm
Administrator
Posts: 6629
Post Re: Scripting support
on: January 30, 2022 (GMT)

Hi!

Is it possible to send me the broken script to ian@prowl.org? (I don’t judge how tidy/untidy it is! :-))

Where the error is happening will let me add better popups to explain – yes line 21 is where the parser complained (but the actual cause could be the statement before that, something like a missing ‘;’ or ‘}’ (usually a ‘;’ though) :)

Capp777
Member
Posts: 2994
Post Re: Scripting support
on: January 30, 2022 (GMT)

Sent.

Please note that if statement was added after
error began occurring.

Thanks for the help.

Capp777
Member
Posts: 2994
Post Re: Scripting support
on: February 2, 2022 (GMT)

Tried adding just the first popup statement
to a new pushbutton’s script. Same problem.

Apparently there is something wrong with
the popup call that worked the night before.

piemmm
Administrator
Posts: 6629
Post Re: Scripting support
on: February 2, 2022 (GMT)

Hi!

Can you zip the problematic script up and send it to me (the one you sent previously is working fine – I can’t break it despite multiple differnet ways)

A zip won’t alter it so I should be able to extract entirely as was setup on your device and see what’s up

Capp777
Member
Posts: 2994
Post Re: Scripting support
on: February 3, 2022 (GMT)

Zipped file sent as requested.

Tried creating under a different
profile. Same errors.

piemmm
Administrator
Posts: 6629
Post Re: Scripting support
on: February 3, 2022 (GMT)

Hi!

You managed to segfault my text editor with that script, well done! :)

It looks like it’s balking at the hard spaces in the file (alt-160, (or c2a0 unicode).Taking them out should solve the problem as I don’t think the parser likes them (however I’ll see what I can do to sort this out) – still looking into this but that’s what I’ve seen so far.

edit: some other stuff is going on too, still looking

piemmm
Administrator
Posts: 6629
Post Re: Scripting support
on: February 3, 2022 (GMT)

Hi

First script – you’re using popup() and not blockingPopup() which takes different arguments to the function which is why it’s unhappy :)

Second script (the larger script) you’ve commented out the if (but left the ‘else {‘ part behind, so the parser doesn’t like it :-))

Pages: [1] 2
WP-Forum by: Fredrik Fahlstad, Version: 2.4
Page loaded in: 0.078 seconds.

  Follow me on twitter