Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script is not working with 2.3.15 #7

Closed
skaman82 opened this issue May 16, 2022 · 12 comments · Fixed by #9
Closed

Script is not working with 2.3.15 #7

skaman82 opened this issue May 16, 2022 · 12 comments · Fixed by #9
Labels
question Further information is requested

Comments

@skaman82
Copy link

Since I have updated my TX16S to OpenTX 2.3.15 (from 2.3.10) the script is no longer working. I get no LTM output.
The strange thing is, when I tried your old initial version (without the config file), it is working. If you need more info, let me know.

@stronnag
Copy link
Owner

Thanks. Probably thinks it's EdgeTX (where it does work) and using an inappropriate serial API.
Fix soon.

@stronnag
Copy link
Owner

Too soon. Should not be that, as the serialbaud API is common after 2.3.12. Leave it with me, I may need more info, just don't know what yet.

@stronnag
Copy link
Owner

I've modified the way the LUA serial baud rate is set; previously if the config file specified 115200, nothing was done because this was the default. In EdgeTX (and possibly in OpenTX), this is no longer a valid assumption.

  • In branch update_set_baud_rate
    • The baud rate is get from the config file unless it is configured as <= 0

Working on EdgeTX 2.7(.1), and seems to be generating messages in companion2.3.15

Can you give the changed files (ltm.lua, LTM/config.lua) from update_set_baud_rate (and in the Zip file) a test?
ltmlua-serial.zip

@skaman82
Copy link
Author

skaman82 commented May 16, 2022

Unfortunately no luck. If I try to execute the ltm.lua directly I also get an error message saying : "?:0 attempt to call nill value"
EDIT:I am getting the same error message also with the current master version

@stronnag
Copy link
Owner

Thanks for trying.
I'm not sure you can execute the scripts directly.
Can you see what the default baud is set too, and

  • Set it to the rate you desire
  • Set the lau script config baudrate to 0 (so the script doesn't set it).

Otherwise I'm rapidly running out of ideas. I'd prefer not to have to flash my radio back to OpenTX.

@stronnag
Copy link
Owner

stronnag commented May 17, 2022

OK, I relented and flashed my TX16S back to OpenTX

  • 2.3.14: Works perfectly
  • 2.3.15: Also works perfectly

In both cases, valid data displayed in mwp via BT bridge.

UART1 set to LUA, Max Bauds set to 115k, S.baudrate in config.lua also set to 115200.

@stronnag
Copy link
Owner

stronnag commented May 17, 2022

By not working do you mean:

  • Nothing is output on the UART; or
  • Something is output, but it's not valid LTM ?
  • Please also confirm the baud rate you have set for the LUA port in OTX?

@stronnag stronnag added the question Further information is requested label May 26, 2022
@sashgorokhov
Copy link

sashgorokhov commented Jul 24, 2022

  • The problem is in
   elseif fm == "CRS" or fm == "3CRS" or fm == "CRSH" || fm == "CRUZ" then

|| seems confusing lua. I have no idea why it is not working for me, but changing from || to or fixed all issues.

Probably because I'm a very occasional LUA developer.
I you want your "name in lights", please generate a PR, otherwise I'll apply the change.

@sashgorokhov
Copy link

screen-2022-07-24-171138
screen-2022-07-24-171152
screen-2022-07-24-171159
screen-2022-07-24-171132

@stronnag
Copy link
Owner

Apologies, I broke your comment above.
Anyway, please either generate a PR (or I'll make one).

@stronnag
Copy link
Owner

And apropos the loadScript syntax.

  • The 2nd, 3rd parameters are optional
  • The second set of (params...) provides parameters to the loaded script. It's pretty common usage.
  • The second return parameter is not much help, if the scripts fail to load or parse, we cannot continue anyhow.

@stronnag
Copy link
Owner

stronnag commented Oct 6, 2022

For posterity, here's the comment I erroneously broke, that demonstrates (last line) that the script works with CRSF.

Hey @stronnag!
This script is not working for me too on a freshly flashed 2.3.15 on radiomaster tx16s. (and was not working on 2.3.14)

I uploaded scripts with your instructions
Enabled logging inside config file (S.LOGGER = true)
Added lua script into global functions with ON trigger
Set serial 2 as LUA in system settings
Script is not working (literally) because:

I dont see any log file created in LOGS/ but your code should've created it
Connecting USB-TTL to serial 2 and serial monitor feed is empty. (if i change serial 2 output to telem mirror i can see characters flowing).
For some reason script just fails to start. If I execute it directly, it says ?:0 attempt to call nill value. Executing csrf.lua errors ``then expected near '|' at line 79.

Any thoughts why this particular lua script fails to run?

UPD:

I've added debug points, removed reading config.lua (pasted contents straight into ltm.lua). The way you use loadScript function is kinda strange and does not align what opentx docs say about this function. It returns tuple func, err but you are using loadScript()(). I am not a lua expert but this seems weird. So as i said i've added debug prints and this script fails at the moment it tries to load csrf.lua script.
The problem is in
elseif fm == "CRS" or fm == "3CRS" or fm == "CRSH" || fm == "CRUZ" then
|| seems confusing lua. I have no idea why it is not working for me, but changing from || to or fixed all issues.

This is the fix in #9 / v0.0.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants