enter_alt()if not get_mode() then switch_mode_usb(1) while get_mode() ~= true do sleep(100) endendset_zoom_speed(100)set_zoom(60) -- value does not matter.return get_zoom()
from ptp import PTPDevice, CHDKScriptStatusimport sysfrom time import sleepd = PTPDevice()id = d.chdkExecLua(""" enter_alt() if not get_mode() then switch_mode_usb(1) while get_mode() ~= true do sleep(100) end end set_zoom_speed(100) set_zoom(%i) return get_zoom()""" % int(sys.argv[1]))while d.chdkScriptStatus(id) & CHDKScriptStatus.MSG == 0: sleep(0.050)print d.chdkReadScriptMessage()
That's quite strange that enter_alt should matter. How sure are you this is actually a determining factor, rather than random coincidence?
import setup_pathfrom ptp import PTPDevice, CHDKScriptStatusimport sysfrom time import sleepdef zoom(d, v): id = d.chdkExecLua(""" --enter_alt() if not get_mode() then switch_mode_usb(1) while get_mode() ~= true do sleep(100) end end set_zoom_speed(100) set_zoom(%i) return get_zoom() """ % v) while d.chdkScriptStatus(id) & CHDKScriptStatus.MSG == 0: sleep(0.050) print d.chdkReadScriptMessage()d = PTPDevice()z1 = int(sys.argv[1])z2 = int(sys.argv[2])count = 0run = Truewhile run: count += 1 try: zoom(d, z1) zoom(d, z2) except Exception, e: print "error", type(e), e print "loops", count run = False
--enter_alt() if not get_mode() then switch_mode_usb(1) while get_mode() ~= true do sleep(100) end end sleep(1000) set_zoom_speed(100) set_zoom(%i) return get_zoom()
enter_alt() if not get_mode() then switch_mode_usb(1) while get_mode() ~= true do sleep(100) end end set_zoom_speed(100) set_zoom(%i) return get_zoom()
If you get a romlog http://chdk.wikia.com/wiki/Debugging#Camera_crash_logs_.28romlog.29 that may shed some light on what is crashing.Two logs attached; those from runs 3 and 4 will follow in another message.Have you tried putting an additional delay between the switch_mode_usb() and the set_zoom()? I wouldn't be totally surprised if get_mode could change before everything was completely done.
And yes, I know, all this sounds a bit weird ... and of course I can't rule out any bugs in my Python library...
The only bug I could see causing this kind of behavior is if you try to start a script while one is already running.
import setup_pathfrom ptp import PTPDevice, CHDKScriptStatus, CHDKMessageTypeimport sysfrom time import sleepdef zoom(d, v): id = d.chdkExecLua(""" --enter_alt() if not get_mode() then switch_mode_usb(1) while get_mode() ~= true do sleep(100) end end set_zoom_speed(100) set_zoom(%i) return get_zoom() """ % v) assert d.chdkScriptStatus(id) & CHDKScriptStatus.RUN == 1 while d.chdkScriptStatus(id) & CHDKScriptStatus.MSG == 0: sleep(0.050) val, type_, res_id = d.chdkReadScriptMessage() print val, type_, res_id assert d.chdkScriptStatus(id) & CHDKScriptStatus.RUN == 0 assert res_id == id assert type_ == CHDKMessageType.RETd = PTPDevice()z1 = int(sys.argv[1])z2 = int(sys.argv[2])count = 0while True: count += 1 try: zoom(d, z1) zoom(d, z2) except Exception, e: print "loops", count raise
Same as before: The camera crashes (ptp.PTPError: (765, 'unexpected return code 0x2fd')), once it happened already in the 11th loop run.
Assuming i didn't mess up completely with constant definitions and mapping the data retruned by read_script_message() to Python objects, I am pretty confident that this is the only script that was running.
Quote from: adeuring on 09 / January / 2013, 17:59:29Same as before: The camera crashes (ptp.PTPError: (765, 'unexpected return code 0x2fd')), once it happened already in the 11th loop run.This is PTP_ERROR_RESP_EXPECTED in the ptpcam code (not an actual USB error). This appears exactly once, in ptp_usb_getresp. I expect that just means the camera crashed, although in my experience PTP_ERROR_IO is more common when the camera crashes. May depend on the host OS.
Quote Assuming i didn't mess up completely with constant definitions and mapping the data retruned by read_script_message() to Python objects, I am pretty confident that this is the only script that was running.Based on the romlogs, I'd say that was a long shot start. I'd expect kbd task or possibly the ptp task to crash in that case, while your romlogs seem to point to Canon zoom related code.I'll try to reproduce it on my cameras when I get some time.
set_zoom_speed(100)exit_alt()count = 0while count < 100 do print(count) set_zoom(60) sleep(500) set_zoom(1) sleep(500) count = count + 1end
Nice job with the python interface btw, feel free to add information about it to the wiki if you want. Suggestions and improvements for the ptpcam based code and API are also welcome.
Started by Microfunguy General Discussion and Assistance
Started by trackuino LUA Scripting
Started by geoffire « 1 2 3 » General Discussion and Assistance
Started by joelmeijering General Help and Assistance on using CHDK stable releases
Started by nod5 General Discussion and Assistance