I'm running into a problem with overlapped commands - I know that if you run a second command before the first has completed, that PTP crashes. The problem I'm having is trying to detect when an action has completed. Currently I call ptp_chdk_exec_lua(), then I poll ptp_chdk_get_script_status() until Status doesn't have PTP_CHDK_SCRIPT_STATUS_RUN set (sleeping 50ms each loop). This seems to work in most cases, but in a couple it doesn't - the most obvious example is trying to use the lua "set_aflock(0);" In my script I toggle it, so that it sets the focus, then disables autofocus.
Now, it returns almost immediately from "set_aflock(0);", so when I issue "set_aflock(1);", the camera crashes. I could combine the two, like "set_aflock(0);set_aflock(1);", but then it crashes on the next command. Right now my terrible terrible workaround is to do this:
set_aflock(0);press(\"shoot_half\"); repeat sleep(50); until get_shooting() == true; release(\"shoot_half\"); repeat sleep(50); until get_shooting() == false;
which works, but does a ton of other stuff that's irrelevant to what I'm trying to do.
My question is, is this the expected behavior with set_aflock(), and if so, how can I wait until it's completed?