Check camera status - General Help and Assistance on using CHDK stable releases - CHDK Forum

Check camera status

  • 4 Replies
  • 1584 Views
Check camera status
« on: 08 / September / 2014, 12:57:39 »
Advertisements
Hello!

My problem is that when I send two PTP commands to camera - something like PTP_CHDK_DownloadFile while something else is in progress, say it's PTP_CHDK_GetDisplayData camera may freeze.(black screen, not responding to any of buttons, only removing the batteries will turn it off.) or, usually my program would crash with LibUsb error, or it just may also freeze.

I have no idea how to check if camera is busy or is it ready. There is ScriptStatus to check if script is runnig but I have not found a way to check if camera is busy doing something PTPish.
So my question is how to check devices status because when the camera freezes it sucks:)

And... is it right place to post this type of questioins? Sorry, just being new here:)

*

Offline reyalp

  • ******
  • 12072
Re: Check camera status
« Reply #1 on: 08 / September / 2014, 22:42:28 »
My problem is that when I send two PTP commands to camera - something like PTP_CHDK_DownloadFile while something else is in progress, say it's PTP_CHDK_GetDisplayData camera may freeze.(black screen, not responding to any of buttons, only removing the batteries will turn it off.) or, usually my program would crash with LibUsb error, or it just may also freeze.
As far as I know, PTP can only handle one transaction at a time. So you need to make sure you requests are sequential. This would be entirely in your client code using thread synchronization objects or something, not involving any USB or PTP calls.

chdkptp does this naturally due to being entirely single threaded ;)

Quote
And... is it right place to post this type of  questioins? Sorry, just being new here:)
"Creative Uses of CHDK" or "General Discussion and Assistance" might be a little more on topic, but it's not a problem either way.
Don't forget what the H stands for.

Re: Check camera status
« Reply #2 on: 09 / September / 2014, 19:07:26 »
Quote
As far as I know, PTP can only handle one transaction at a time. So you need to make sure you requests are sequential.
Thanks for pointing that out. It really solved the problem after I re-checked my threads!
I've had separate steam for live view and it was really the problem.
Now I think I'll do command queue.

Re: Check camera status
« Reply #3 on: 10 / September / 2014, 11:39:11 »
Quote
camera may freeze.(black screen, not responding to any of buttons, only removing the batteries will turn it off.)
It happens if while shutter is still opening second switch_mode_usb() is sent. What can I do about that?

Also, is it normal that when switching back to playback mode shutter won't close? Now even if w/o CHDK.


*

Offline reyalp

  • ******
  • 12072
Re: Check camera status
« Reply #4 on: 10 / September / 2014, 22:12:19 »
Quote
camera may freeze.(black screen, not responding to any of buttons, only removing the batteries will turn it off.)
It happens if while shutter is still opening second switch_mode_usb() is sent. What can I do about that?
Don't send a second switch_mode_usb() until the switch is done? chdkptp has code to wait until the switch is complete, and not attempt to switch into a mode that you are already in. From cli.lua

Code: [Select]
local rstatus,rerr = con:execwait([[
if not get_mode() then
switch_mode_usb(1)
local i=0
while not get_mode() and i < 300 do
sleep(10)
i=i+1
end
if not get_mode() then
return false, 'switch failed'
end
return true
end
return false,'already in rec'
]])
Everything in the [[ ]]  is the camera side code.

Quote
Also, is it normal that when switching back to playback mode shutter won't close? Now even if w/o CHDK.
By "shutter" you mean the lens cover? Normally there is a timeout before the lens retracts. You may be able to adjust this in the canon settings menu.
Don't forget what the H stands for.

 

Related Topics