{"action":"created","issue":{"url":"https://api.github.com/repos/opentx/opentx/issues/1966","labels_url":"https://api.github.com/repos/opentx/opentx/issues/1966/labels{/name}","comments_url":"https://api.github.com/repos/opentx/opentx/issues/1966/comments","events_url":"https://api.github.com/repos/opentx/opentx/issues/1966/events","html_url":"https://github.com/opentx/opentx/issues/1966","id":53229053,"number":1966,"title":"telemetry script error","user":{"login":"wolkstein","id":1617000,"avatar_url":"https://avatars.githubusercontent.com/u/1617000?v=3","gravatar_id":"","url":"https://api.github.com/users/wolkstein","html_url":"https://github.com/wolkstein","followers_url":"https://api.github.com/users/wolkstein/followers","following_url":"https://api.github.com/users/wolkstein/following{/other_user}","gists_url":"https://api.github.com/users/wolkstein/gists{/gist_id}","starred_url":"https://api.github.com/users/wolkstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolkstein/subscriptions","organizations_url":"https://api.github.com/users/wolkstein/orgs","repos_url":"https://api.github.com/users/wolkstein/repos","events_url":"https://api.github.com/users/wolkstein/events{/privacy}","received_events_url":"https://api.github.com/users/wolkstein/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-01-01T21:24:08Z","updated_at":"2015-01-03T18:15:46Z","closed_at":null,"body":"hi,\r\ni get a telemetry script error with an script which run fine on taranis.\r\ni can surly reproduce this error.\r\n\r\n1. telemetry script error happened\r\n  1. power taranis and stay on main screen\r\n  2. power the model\r\n  3. switch to telemetry view\r\n  4. display show telem1 script error\r\n\r\n2. no telemetry script error\r\n 1.  power taranis and switch to telemetry screen\r\n 2. power the model\r\n 3. telemetry script and and screen works correct.\r\n\r\nmy telemetry script use an background function. in error case(1) the script background function runs fine and i get audio output, for example my flightmodes. if i switch to the telemetry screen the error happens and also the background function from script is gone.\r\n\r\ni try to make an small video with my handy(shaky). however, it demonstrate how i start the taranis and power my model to reproduce the error. also in error case i switch flightmodes before and after i enable the telemetry screen.\r\nthe second part of the video show how i power on the taranis and power my model without the 100% reproducible error case.\r\n\r\nhttps://www.youtube.com/watch?v=C6rSBsiqgeE\r\n\r\ni try this procedure more than 10 times one after another. and i reproduce the error to 100%.\r\n\r\nmy script is located here:\r\nhttps://github.com/wolkstein/MavLink_FrSkySPort/blob/s-c-l-v-rc/Lua_Telemetry/DisplayApmPosition/SCRIPTS/Model_Name/telem1.lua\r\n\r\n/g\r\nwolke"},"comment":{"url":"https://api.github.com/repos/opentx/opentx/issues/comments/68603929","html_url":"https://github.com/opentx/opentx/issues/1966#issuecomment-68603929","issue_url":"https://api.github.com/repos/opentx/opentx/issues/1966","id":68603929,"user":{"login":"projectkk2glider","id":5950438,"avatar_url":"https://avatars.githubusercontent.com/u/5950438?v=3","gravatar_id":"","url":"https://api.github.com/users/projectkk2glider","html_url":"https://github.com/projectkk2glider","followers_url":"https://api.github.com/users/projectkk2glider/followers","following_url":"https://api.github.com/users/projectkk2glider/following{/other_user}","gists_url":"https://api.github.com/users/projectkk2glider/gists{/gist_id}","starred_url":"https://api.github.com/users/projectkk2glider/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/projectkk2glider/subscriptions","organizations_url":"https://api.github.com/users/projectkk2glider/orgs","repos_url":"https://api.github.com/users/projectkk2glider/repos","events_url":"https://api.github.com/users/projectkk2glider/events{/privacy}","received_events_url":"https://api.github.com/users/projectkk2glider/received_events","type":"User","site_admin":false},"created_at":"2015-01-03T18:15:46Z","updated_at":"2015-01-03T18:15:46Z","body":"@wolkstein I looked at your script. You have quite a few variables that are uninitialzied. Only one example that could cause your issue:\r\n\r\nThe variable `prearmheading` is un-initialized, this means its value is `nil` (http://www.lua.org/pil/2.1.html).\r\n\r\nThat varable is assigned in function:\r\n```lua\r\n\tlocal function armed_status()\r\n\t  \r\n\t  t2 = getValue(210)\r\n\t  apmarmed = t2%0x02\r\n\t \r\n\t  --prearmheading =63\r\n\t  if apmarmed ~=1 then -- report last heading bevor arming. this can used for display position relative to copter\r\n\t    prearmheading=getValue(223)\r\n```\r\nBut only if `apmarmed` is at certain value. So if you miss this assignment and try to use it, for example here:\r\n```lua\r\n\tlocal function drawArrow()\r\n\r\n\t  sinCorr = math.sin(math.rad(getValue(223)-prearmheading))\r\n\t  cosCorr = math.cos(math.rad(getValue(223)-prearmheading))\r\n```\r\nYou will get an error, example:\r\n```\r\n$ lua\r\nLua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio\r\n> local foo\r\n> print (5-foo)\r\nstdin:1: attempt to perform arithmetic on global 'foo' (a nil value)\r\nstack traceback:\r\n\tstdin:1: in main chunk\r\n\t[C]: in ?\r\n```"}}