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

4 of 4 related issues to LUA io library #3003

Closed
sbright33 opened this issue Oct 27, 2015 · 6 comments
Closed

4 of 4 related issues to LUA io library #3003

sbright33 opened this issue Oct 27, 2015 · 6 comments

Comments

@sbright33
Copy link

io.write(fh,"any string") is OK
io.write(fh,stringvarname) is OK
io.write(fh,numvarname) writes .14g to the file
io.write(fh,2) writes .14g
io.write(fh,2.2) writes .14g

This is only on Taranis. All good on PC sim. That's how I know my syntax is correct?

@projectkk2glider
Copy link
Member

Can you post the whole Lua script as an example that demonstrates all three issues you have: opening file, writing to it and closing. Tnx.

@projectkk2glider projectkk2glider added this to the OpenTX 2.1.X milestone Oct 27, 2015
@projectkk2glider
Copy link
Member

Confirmed, the problem is that Lua in this case uses f_printf() with format string ".14g" which is not supported by ff.c.

@sbright33
Copy link
Author

So it's ready for me to test? How do I download this version you fixed? Sorry, I'm new to Github, and never built this project. Can you make it easy for me?

@projectkk2glider
Copy link
Member

The fixes are not yet in main branch, so they are not available in nightly builds. I can prepare a custom build for you, but for that I need to know which radio you have: Taranis, Taranis Plus or X9E? And which language?

@sbright33
Copy link
Author

T Plus. English. Thanks!

@projectkk2glider
Copy link
Member

Here is your bin file: http://downloads-21.open-tx.org/test/opentx-taranisplus-lua-en-2.1.5-io.bin

Here is a version with cli option enabled:http://downloads-21.open-tx.org/test/opentx-taranisplus-cli-lua-en-2.1.5-io.bin (read #3000 (comment) first!)

Here is my small standalone script (execute from the SD browser):

local function run(event)
  print("c1")
  local f = io.open("foo.bar", "a")
  io.write(f, "first line\r\nsecond line\r\n")
  io.write(f, 4, "\r\n", 35.6778, "\r\n")  -- one can write multiple items at the same time
  local foo = -4.45
  io.write(f, foo, "\r\n")
  io.close(f)
  return 1    -- this will end the script execution
end

return { run=run }

Remember that you are working with unofficial OpenTX release, so use it with caution preferably not with any expensive model. Also make a backup of your EEPROM before flashing (just in case something goes wrong).

The Lua io library is somewhat different from the official version, you can find preliminary docs here: opentx/lua-reference-guide#3

Report back on your findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants