I haven't quite mastered Lua yet. Does anyone have a Lua script that can automatically deactivate and restart a probe?
Depends on what you mean by "automatically"...
A script that deactivates and activates a probe is easy. The bigger trick is probably working out how the script gets triggered. But even that should usually be fairly easy.
A script would be something like this:
local robot_addr = "controller"local probe_name = "cdm"local delay = 5000local args = pds.create()pds.putString(args, "name", probe_name)local resp,rc = nimbus.request (robot_addr, "probe_deactivate", args)if rc ~= NIME_OK then print("Failed to deactivate "..probe_name.." on "..robot_addr.." (error = "..rc..")") returnendsleep(delay)resp,rc = nimbus.request (robot_addr, "probe_activate", args)if rc ~= NIME_OK then print("Failed to activate "..probe_name.." on "..robot_addr.." (error = "..rc..")") returnendprint("Successfully restarted "..probe_name.." on "..robot_addr)
The script is pretty basic but does have error checking on the two requests. I am not sure if you really need to put any delay in there, so I included it to be conservative. You would need to change the variables at the top as needed or set them based on information in an alarm. If you run this outside the NAS, you might need to replace the return statements with the os.exit() function. You would probably also have to add a call to the nimbus.login() function.
Retrieving data ...