chdkptp general question - returning chdkptp errorlevels?

Using linux source-built chdkptp on the ixus160_elph160. This software, as well as CHDK, is awesome. Life-changing for my project.

I'd like to learn more about how to best utilize exit codes (aka errorlevels) when using CHDK and chdkptp.

I'm looking for a way to inform my process running on the PC that a chdkptp command succeeded or failed. I suspect that it can be done (probably has already been done) with lua. Or maybe the Pixhawk thing.. Reading more at User Contributed scripts and CHDK/LUALIB, trying to get my head around this.. Simple is better.

In my app, the PC drives. It is good to inform the driver about command success or fail.. Getting closer to what I want by;

I could write something to parse the redirected stdout/stderr from chdkptp, looking for these kinds of exit codes, but I suspect there's a better way.. Any pointers to where I might learn more about this aspect of chdkptp use are most appreciated.

rc file IMG_0028.jpg 1rc chunk get IMG_0028.jpg 1 0rc chunk size:8704 offset:nil last:falserc chunk get IMG_0028.jpg 1 1rc chunk size:1784368 offset:nil last:trueNote if you requested more than one data type (raw data, dng header, jpeg) you will get a 'last' for each one. The types are always requested in the same order.

con 11> !t=cli:execute 'remoteshoot('/home/foo/Videos','-jpeg',{"shots=1"})' The shot is successful. Output from the cmd in chdkptp is more verbose, and appears to give a status code of 1

I assume the error is related to bad Lua syntax - but did I understand you correctly about the errorlevel output I should expect to see?

In this case, the there was a lua error() trying to run you command, so you got a stack trace. The :1 at the very end means it was in line 1 of the code you gave to the ! command. This will pretty much always be 1, because you can only enter one line from the console.

The stuff further up the stack trace should give you a better idea of where the error happened. I'm not sure exactly what failed because the line numbers don't appear to match the current chdkptp source, but the use of cli:execute wasn't quite correct.

cli:execute expects a single string, just as you would enter on the command line. So for remoteshoot, you could do something like

!status,msg=cli:execute'remoteshoot /home/foo/Videos -jpg -shots=1' if msg then print(msg) end if not status then os.exit(1) endThis will print any output or error message from the command, and then exit chdkptp with a status code of 1 if the command failed. It prints msg regardless of status because some cli commands return their output on success.

If you need to build the remoteshoot command with code, getting the path from a variable or something like that, you can use the string concatenation operator ..., or string.format like

I believe I'm using chdkptp version 676 from the assembla site. The failing lua command was me modifying what I saw in USAGE.TXT : line 613, as a quick & dirty test. But the examples you've just provided are *exactly* what I need to go forward. Thanks again!