← All tools

Message & Error Explainer

What an ArduPilot message means and what to do about it

Українська

A Lua script stopped with an error

WarningBoard, internal errors, CAN, scripting

What ArduPilot says:

Also explained here: 3 more
  • Panic: …
  • … did not return a function (0xN)
  • … returned bad result count (N)

Script errors reach you as “Lua: …”, usually with the file name and the line number. “Error: …” means the file could not even be read as Lua (a syntax error); other texts are errors met while running. “did not return a function”, “did not return a delay” and “returned bad result count” mean the script's update function did not end the way ArduPilot expects: with the function to call next and the delay in milliseconds. The failed script is removed and not run again; the others carry on. The line is repeated every 10 seconds, ten times.

What to do, most likely first

  1. The script was written for another firmware version, and a function it calls has changed or is missing.

    CheckThe text says “attempt to call a nil value” or “bad argument”, with a line number.

    FixTake the script from the same version as your firmware; the Lua Applet Catalog lists every applet per version.

  2. The script needs something that is not there: a module file, its own parameters, a device.

    Check“module … not found” means a file is missing from APM/scripts/modules. Read the applet's own instructions for the parameters it expects.

    FixCopy the modules next to the script, set the parameters it asks for, and reboot.

  3. A mistake in your own script.

    CheckGo to the line number in the message.

    FixCorrect it and reboot or restart scripting. An update function must end with a line like “return update, 100”.

“Panic: …” (4.6) and “Engine Error: …” (4.7) are errors in the engine itself, outside any one script. 4.6 throws all scripts away and loads them again from the start; 4.7 ends the engine, and “Scripting: stopped” follows.

Parameters to look at

ParameterWhat it is
SCR_ENABLEEnable Scripting
SCR_DEBUG_OPTSScripting Debug Level
The code that sends it

Error: …

libraries/AP_Scripting/lua_scripts.cpp lua_scripts::load_script() · Open in ArduPilot Copter-4.7.1

Unable to load the file: …

libraries/AP_Scripting/lua_scripts.cpp lua_scripts::load_script() · Open in ArduPilot Copter-4.7.1

Unknown error (N) loading …

libraries/AP_Scripting/lua_scripts.cpp lua_scripts::load_script() · Open in ArduPilot Copter-4.7.1

Engine Error: …

libraries/AP_Scripting/lua_scripts.cpp lua_scripts::run() · Open in ArduPilot Copter-4.7.1

And 5 more messages, sent from the same places.

Written here for Copter 4.6. In the tool you choose your vehicle and version, see your own parameter values beside the ones named here, and drop a flight log to have every message in it explained.

Open it in the Message & Error Explainer