I am using ptpcam in python to control the Z1. After I send a commend, I search for the key word and use that for conforming the task is success. If it cannot find it, I just resend the command again. This method is working okey, but I wonder if there is better and smarter way to confirm a task is done. Below is a one of the function I use to capture the image. Thanks.
def Capture():
cmdCapture = ["ptpcam", "--capture"]
isSuccess = False
retryNum = 0
while not isSuccess:
process = subprocess.Popen(cmdCapture,stdout=subprocess.PIPE)
process.wait
status = process.communicate()[0].decode('ascii')
if "successfully" in status:
isSuccess = True
return isSuccess
elif retryNum <= MaxTryNum:
reTryNum =+1
time.sleep(2)
continue
else:
return False