Script execution speed. In principle, let us say I write a 200 line script and want to operate strictly from the client (from the user-perspective fully flexible remote), for example, modifying a few parameters and then re-issuing the code on the fly.
200 lines is not much. Achieved bulk transfer rate with USB 2.0 is at least several megabytes a second. This varies depending on the camera, newer cameras are faster. In the live view, the "last xfer kb/s" is a pretty good indicator of bulk throughput. Each transaction has overhead, which is a few ms at the minimum. I see ~5ms average for d10 and ~10ms for a540, both vary by about +10/-3. Bottom line, in most cases, it shouldn't matter if your script is 10 bytes or 1kb. The number of transactions tends to matter more.
You can use
set cli_time=true
to see the execution time of a command. This is the total time for the command to complete on the client, so if you do something that waits (e.g. =return 1) all the waiting is included too.
How do you handle this? Do you execute each small chunk of a function on the client with handshaking? Do you transfer the entire file to camera RAM (or SD temp file) and transparently execute from there?
The chdkptp CLI and GUI commands work by building the script on the fly and sending the entire thing over. This is done for simplicity. If you look at chdku.lua con_methods:exec you can see how it's done. rlibs.lua contains a bunch of utility code which is combined with the script to execute. So if you do something like
=return 1
It's actually loading prepending the 'serialize_msgs' code from rlib (76 lines, 1.6 kb) to whatever you enter, sending it to the camera, polling until script execution ends, fetching the return message. Many of the chdkptp cli commands load a lot more code.
How best should I handle this?
"Best" depends on your application. Does a few milliseconds matter ? How much code do you want to write ?
Eg, will the operation execute faster if I write the file to SD and give CHDK the command to execute it, or is there really not much difference from sending the entire script file from CHDKPTP?
I haven't benchmarked loading from the card (would depend a lot on card speed), but I would guess with a modern camera and USB 2.0, there is very little reason not to send it over USB.
If you want the absolute minimum latency, then you should write a script that runs continuously on the camera and uses the message interface. The multicam.lua file is an example of this.
How do I transmit a multi-line script to the camera from CHDKPTP? Is there another way outside of CHDKPTP to do it?
I answer this before, see the end of this post
http://chdk.setepontos.com/index.php?topic=8585.msg89772#msg89772In your docs you have an example titled "Universal Tv Mode." Very basically, how would I have to simplify the code for a remote scenario where I give it a Tv parameter in a function I wrote, from the client?
I haven't looked at this script, but to set the Tv value, you probably want to use set_tv96_direct. This must be called *before* you press half shoot to take the shot. Most of the exposure related functions and propcases work in APEX*96 values. The 96 in the name tells you this one does too. So to set a 1 second exposure, you would use
.set_tv96_direct(0)
Where/how do I find/extract the translation table of Tv index versus shooting speed (property case name?), for example?
I suggest using the APEX values rather than any of the functions that take indexes. APEX is your friend. On the off chance you aren't familiar with it,
http://dougkerr.net/Pumpkin/#APEX is an excellent reference. The camera uses APEX*96 so it can work in all integer math.
If you want to use traditional (e.g. "1/250th") values, I'd suggest doing the conversion on the PC side, since PC side Lua has floating point math. Alternately, you could just make a lua table mapping the strings to the APEX*96 values.
A further wrinkle when dealing with ISO is the "real" vs. "market" values, discussed here:
http://chdk.wikia.com/wiki/CHDK_User_Manual#Override_ISO_value - CHDK generally works with the "real" values.
Please don't dig for an answer if you don't have it at hand. Question is related to image file transfer speed on a USB 2.0 port. For example, the S50 is very slow, ~10s for a big 4 MB JPG. The S70 which Canon promotes as sporting USB 2, is only marginally faster. The SX110 on the other hand is super fast ... a split second for a 6 MB JPG. Would you have an idea how the S90, S95, perform?
I would expect any new cameras to be as good or better than the sx110. My d10 (digic 4, newer than sx110) shows 10-20mb/sec for live view. My a540 (Digic 2, older than sx110) shows 5-10. The S90 and S95 should be as good or better than the D10.