Author Topic: Lua Q&A  (Read 105542 times)

0 Members and 2 Guests are viewing this topic.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Lua Q&A
« Reply #45 on: August 18, 2011, 11:08:53 am »
That above string just error's when I enter it into my calculator. Maybe because its running in a coroutine.

Offline NecroBumpist

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 130
  • Rating: +14/-5
  • Master of Lua
    • View Profile
Re: Lua Q&A
« Reply #46 on: August 18, 2011, 11:27:43 am »
It should have caused a segfault in the loadstring() function.
It does with normal Lua, maybe it's just not a problem on ARM. Oh well.

Anyway, what software am I supposed to use to update to OS 3 ?
I downloaded the 3.0.2.1791 .tno from TI's website, and the TI NSpire Student Software, but that seems to be a trial, and isn't recognizing my calculator. (then again, I'm not using the cord that came with it)
Any suggestions ?
Developing Lua scripts for the NSpire ?
Check out the Necrotorium
Need a few routines to run faster ? Checkout the MODS Lua Assembly Toolkit.
Need to save space for your scripts ? Checkout LuaSrcDiet

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Lua Q&A
« Reply #47 on: August 18, 2011, 11:29:38 am »
Hm, should work. I didn't have any problems. I hope it isn't because its trial x)
Maybe your cable is a bit damaged?

Offline NecroBumpist

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 130
  • Rating: +14/-5
  • Master of Lua
    • View Profile
Re: Lua Q&A
« Reply #48 on: August 18, 2011, 11:31:49 am »
That's a possibility.
I couldn't find the original cable, so I stole one from this weird USB-laptop speaker thingy. I'll continue searching for another cable.
Developing Lua scripts for the NSpire ?
Check out the Necrotorium
Need a few routines to run faster ? Checkout the MODS Lua Assembly Toolkit.
Need to save space for your scripts ? Checkout LuaSrcDiet

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: Lua Q&A
« Reply #49 on: August 18, 2011, 11:35:25 am »
The cable for connecting the Nspire to the computer is a standard USB A <-> mini-USB B cable :)

BTW, never transfer unmodified OS 3.x versions to a Nspire Clickpad or Touchpad. As described in various news and forum topics here and elsewhere, use TNOC to remove the boot2 3.0 upgrade. It will preserve your ability to downgrade, through DowngradeFix, which is a specially crafted fake OS upgrade exploiting a stack-based buffer overflow in boot2 1.4 to kill the "minimum accepted OS version" information set by OS 2.1.0.631 and 3.0.2.1791 :)
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Lua Q&A
« Reply #50 on: August 18, 2011, 11:37:08 am »
Yes, I forgot to mention that. Thanks Lionel :)

Offline NecroBumpist

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 130
  • Rating: +14/-5
  • Master of Lua
    • View Profile
Re: Lua Q&A
« Reply #51 on: August 18, 2011, 11:44:03 am »
Thanks for the tip, I'm downloading TNOC now.
I also managed to find what I believe is the original cable :D This time my computer recognized the device.
Welp, once I get this on I'll be working on trying out Lua assembly and a few lua bugs on my calc :)

Thanks for the help Lionel and Jimbauwens
Developing Lua scripts for the NSpire ?
Check out the Necrotorium
Need a few routines to run faster ? Checkout the MODS Lua Assembly Toolkit.
Need to save space for your scripts ? Checkout LuaSrcDiet

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: Lua Q&A
« Reply #52 on: August 18, 2011, 11:45:22 am »
For direct on-calc testing, you can use oclua; otherwise, use Luna :)
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline NecroBumpist

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 130
  • Rating: +14/-5
  • Master of Lua
    • View Profile
Re: Lua Q&A
« Reply #53 on: August 18, 2011, 11:59:59 am »
On calc Lua editing ? Absolutely epic.

Except for TNOC just crashed twice when I tried to patch my OS. Are the final output files supposed to be TNO_WOB2SA files ?
Anyway, after *trying* to remove the boot2 and examples, I get a file that is 7,672KB large, and with an md5 hash of c76b06af603692518b3e2c30131a5380
Is this the right output ?

Edit: I got it to work without crashing, and it produced a .TNO_WOB2SA file, should I just rename this to a .tno file so TI's student software will see it and install it on my calc ?
« Last Edit: August 18, 2011, 12:16:06 pm by NecroBumpist »
Developing Lua scripts for the NSpire ?
Check out the Necrotorium
Need a few routines to run faster ? Checkout the MODS Lua Assembly Toolkit.
Need to save space for your scripts ? Checkout LuaSrcDiet

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: Lua Q&A
« Reply #54 on: August 18, 2011, 12:21:28 pm »
Quote
I got it to work without crashing, and it produced a .TNO_WOB2SA file, should I just rename this to a .tno file so TI's student software will see it and install it on my calc ?
Yes :)

TNOC crashes pretty often indeed. I've tried to use Valgrind to pinpoint the crash, but there's so much noise in the output (many different causes of improper memory accesses outside of TNOC itself) that it hasn't helped. I'm not sure it would be easy to create meaningful ignore files.

EDIT: I haven't been able to make a meaningful list of suppressions, but
Code: [Select]
valgrind -v --tool=memcheck --num-callers=5 --leak-check=no --malloc-fill=0x55 --free-fill=0xAA ./TNOC_frshows that the code of TNOC 1.21 contains at least one use-after-free error.
When --free-fill=0xAA is passed to valgrind, TNOC cannot open any input file. Tracing the value of variables path and path_2 thusly:
Code: [Select]
else if (error == -2)
{
QMessageBox::critical(this,tr("Attention !"),tr("Fichier Introuvable"));
printf("XYZ \"%s\"\n", path);
printf("XYZ \"%s\"\n", path_2);
}
shows that path is entirely made of 0xAA values...
And, since the only line that modifies path is (because convert_file does not modify its "input" argument):
Code: [Select]
const char* path = LineEdit->text().toStdString().c_str();it means that variable "path" is always invalid in the first place, and that the current code works only accidentally !


Levak ?
« Last Edit: August 18, 2011, 01:21:45 pm by Lionel Debroux »
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline NecroBumpist

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 130
  • Rating: +14/-5
  • Master of Lua
    • View Profile
Re: Lua Q&A
« Reply #55 on: August 18, 2011, 04:36:56 pm »
Wow, this is great! Thanks again for all the help, Lionel and Jimbauwens!
I can't wait to begin exploring some of the API!
Developing Lua scripts for the NSpire ?
Check out the Necrotorium
Need a few routines to run faster ? Checkout the MODS Lua Assembly Toolkit.
Need to save space for your scripts ? Checkout LuaSrcDiet

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Lua Q&A
« Reply #56 on: August 18, 2011, 04:39:33 pm »
I'd suggest you to checkout inspired-lua.org. There most findings/stuff are documented :)
Have fun!

Offline NecroBumpist

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 130
  • Rating: +14/-5
  • Master of Lua
    • View Profile
Re: Lua Q&A
« Reply #57 on: August 18, 2011, 08:21:56 pm »
When you run a script, and then your calculator immediately reboots itself starting from the Loading OS screen, does that mean you did something wrong  :P ?
Developing Lua scripts for the NSpire ?
Check out the Necrotorium
Need a few routines to run faster ? Checkout the MODS Lua Assembly Toolkit.
Need to save space for your scripts ? Checkout LuaSrcDiet

Offline zeldaking

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 197
  • Rating: +15/-0
    • View Profile
Re: Lua Q&A
« Reply #58 on: August 18, 2011, 08:22:55 pm »
I would probably say yes. But then again if I am wrong, punch me.

Offline pianoman

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 426
  • Rating: +24/-0
  • ♪♫ ♪♫ ♪♫ ♪♫ ♪♫ ♪♫ ♪♫
    • View Profile
Re: Lua Q&A
« Reply #59 on: August 18, 2011, 11:28:39 pm »
I'm actually not too sure that its your fault, as usually, the program doesn't crash the calulator, it just tells you about the syntax error.