is it possible to download images while a script is running? - page 2 - General Discussion and Assistance - CHDK Forum

is it possible to download images while a script is running?

  • 63 Replies
  • 10820 Views
*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: is it possible to download images while a script is running?
« Reply #10 on: 26 / October / 2021, 15:52:04 »
Advertisements
it happens as soon as i connect the cable in play mode. (win 10) no chdkptp installed yet.
there isn't even a sound in windows that it recognises a usb device is plugged in with that 9000+ card loaded....so no usb chip saying hello yet on the canon.

in recording mode if i plug in the cable, it retracts the lens goes to play mode and i am left with a black screen, a green led and an irresponsive camera...off/on via play works: in play mode with cable connected the same result.
i can only see the error if i have the cam powered in play mode when i connect the usb cable...
and then it ends the same, with a black screen, green led and only off buttons make the cam responsive again if you disconnect the usb cable..
« Last Edit: 26 / October / 2021, 16:13:29 by Mlapse »
frustration is a key ingredient in progress

*

Offline Caefix

  • *****
  • 947
  • Sorry, busy deleting test shots...
Re: is it possible to download images while a script is running?
« Reply #11 on: 26 / October / 2021, 16:23:10 »
it happens as soon as i connect the cable in play mode. (win 10) no chdkptp installed yet.
https://chdk.setepontos.com/index.php?topic=6341.msg147039#msg147039

The cam might appear without a driveletter?  :-[
All lifetime is a loan from eternity.

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: is it possible to download images while a script is running?
« Reply #12 on: 26 / October / 2021, 16:32:37 »
the cam is not recognised by windows when plugged in with a full card. no handshake, no usb device.

actually the result is similar to plugging in the cam with an empty card,
but then you do hear the sound of a device connecting and you can find the sd card.
only dcim folder visible indeed. cam: black screen, green led.
« Last Edit: 26 / October / 2021, 16:41:12 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14117
Re: is it possible to download images while a script is running?
« Reply #13 on: 26 / October / 2021, 17:56:58 »
it happens as soon as i connect the cable in play mode. (win 10) no chdkptp installed yet.
there isn't even a sound in windows that it recognises a usb device is plugged in with that 9000+ card loaded....so no usb chip saying hello yet on the canon.
Without the libusb driver set up for chdkptp, Windows will attempt to communicate with the camera using standard PTP as soon as the cable is connected. This is likely part of the process where windows recognizes the device, so the behavior may be different after the libusb driver is set up.

I guess I should to fill up a card to test...
Don't forget what the H stands for.


*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: is it possible to download images while a script is running?
« Reply #14 on: 26 / October / 2021, 18:34:24 »
it also was the same after a power down and remove of card, so i'm guessing you can just copy the card full of old images in appropriate folders, no need to actually shoot the card full.

to me it looks like the usb connection is handled by canon instead of the usb chip being always active.

-- if USB_5V=high goto usb mode (black screen, green led) if image_nr <999 power usb_client

« Last Edit: 26 / October / 2021, 18:43:09 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14117
Re: is it possible to download images while a script is running?
« Reply #15 on: 26 / October / 2021, 20:07:17 »
-- if USB_5V=high goto usb mode (black screen, green led) if image_nr <999 power usb_client
The black screen / green LED happens in response to the host sending PTP GetObjectHandles, after the USB link is established and a PTP session has been started (background https://chdk.setepontos.com/index.php?topic=14294.0). On windows, if you have the libusb driver installed, this will not happen on connect.

The "communication error" message is undoubtedly generated by something in the main Camera firmware, at a much higher level than the USB interface, since only the main firmware knows anything about files. IIRC, it does happen with the libusb driver installed, but it's been a long time since I looked into it and I didn't find anything in my notes. Anyway, I'll have card with enough to play with fairly soon.

Some previous discussion about the "communication error" issue, for general reference
https://chdk.setepontos.com/index.php?topic=14446.0
https://chdk.setepontos.com/index.php?topic=4338.msg100743#msg100743

edit:
On elph130, 3109 files was sufficient to trigger the error (this is just how many shots a full battery gave me, so it's not the minimum). "Communication error" appears immediately on connecting USB (with libusb driver configured) so it happens before a PTP sessions starts. In fact, as MLapse suggested, USB power without a USB protocol connection (using a power bank) appears to be enough to trigger it.

On windows, the camera doesn't show up in USBView when the error is triggered, so it does indeed appear to disable the USB interface completely.

Edit:
I compared CameraLogs for connecting USB with and without too many images. The only difference in the USB related sequence was the "too many files" case has
Code: [Select]
UI:LogicalEvent:0x1190:adr:0,Para:0
Sure enough, post_levent_to_ui(0x1190) displays the error message and kills the connection.

This event comes from a massive switch in a function (elph130 100a FUN_ff18cccc) that decides which event to post (among other things) based on R0. R0 == 5 triggers this particular case.

The only place I can see 5 passed is around ff076aa8, based on 0x27bc being 0. When there aren't too many files present, this variable is 0 prior to connecting USB cable, and 1 after. Poking the value to 1 prior to connect avoids displaying the message, but the USB connection still doesn't work, and the camera crashes with "ASSERT!! DiUSB20DM.c Line 401" when the cable is disconnected. I assume it's some kind of connection status, not a "too many files" flag, so additional reverse engineering would be required to figure out how to avoid this case.

Just for completeness, I also confirmed the too many files issue affects wifi connections as well as USB.

edit:
I thought the camera logs might have some indication when the too many files were found at startup, before the USB connection, but camera logs for startup with 1 file and 3109 appear to be functionally identical.
« Last Edit: 27 / October / 2021, 00:57:33 by reyalp »
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: is it possible to download images while a script is running?
« Reply #16 on: 27 / October / 2021, 03:54:51 »
i would think the trigger is not the number of files alone, or it would be a hard 1000 on all cams.
maybe a certain size on disk? since it is code adapted from the fat16-era it might be 4GB....i'm just speculating here  ;)

and i don't think it disables usb, i would rather think that it is only enabled when the 5V line is high and other params are within range...
may have been to save power since usb will most of the time be inactive.
but then again, products that are themselves not powered by 5v often use the 5v input of the usb to power the usb chip.
why there is a switch there to block 5v from reaching the usb client so it can't immediately respond is an interesting question.
it might be that by default it is bypassed to accommodate the remote shutter and prevent the usb client from being fried.

but it would be sweeter to find what calls this switch and see what would happen if you connect when that switch is always active.....i dare to test that  :)
« Last Edit: 27 / October / 2021, 12:45:19 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14117
Re: is it possible to download images while a script is running?
« Reply #17 on: 27 / October / 2021, 12:56:36 »
i would think the trigger is not the number of files alone, or it would be a hard 1000 on all cams.
Yes, you'd think if it was a fixed limit, they'd be less vague
Quote
maybe a certain size on disk? since it is code adapted from the fat16-era it might be 4GB....i'm just speculating here  ;)
FWIW, the 3109 images that triggered it on my cam were 2,199,775,828 bytes. Which is more than 2^31.

I'd be surprised if it was a size limit, because even 4 GB could be a lot less then 1000 large/fine jpeg or Canon raw.

Quote
and i don't think it disables usb, i would rather think that it is only enabled when the 5V line is high and other params are within range...
The camera logs show definitely happens in response to USB power being detected.
Code: [Select]
00022710: UI:Button:0x000010B3:ConnectUSBCable
00022710: UI:IsWirelessConnect?:0
00022710: UI:ChkStoreLens
00022710: UI:IntPcCnct
00022710: UI:DlvrUSBCnct
00022710: UI:_CnctUSBCBR
00022710: UI:LogicalEvent:0x3137:adr:0,Para:0
00022710: UI:LogicalEvent:0x5005:adr:0,Para:0
00022710: PTPRspnd.StartUpPTPFrameworkClient
00022730: UI:LogicalEvent:0x1190:adr:0,Para:0
00022730: UI:ScreenLock
00022730: UI:ScreenUnLock
00022750: UI:IsWirelessConnect?:0
00022750: UI:USBDisconnect
I think the function that logs PTPRspnd.StartUpPTPFrameworkClient is likely related.
Don't forget what the H stands for.


*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: is it possible to download images while a script is running?
« Reply #18 on: 27 / October / 2021, 13:20:16 »

Code: [Select]
00022710: UI:DlvrUSBCnct
00022710: UI:_CnctUSBCBR
00022710: PTPRspnd.StartUpPTPFrameworkClient
I think the function that logs PTPRspnd.StartUpPTPFrameworkClient is likely related.

I acually wouldn't know, but PtpRespond sounds like a good starting point yes.although it could be that the choice is already made if that's called, so then it could be one of the 2 usb connects that calls it.
« Last Edit: 27 / October / 2021, 13:22:19 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14117
Re: is it possible to download images while a script is running?
« Reply #19 on: 27 / October / 2021, 19:22:16 »
Using binary search, I found my elph130 worked with 3084 jpeg files and failed with 3085. This is with 2000 files in one directory and 1084 (or 1085) in another, and no other directories present in DCIM

This is repeatable over multiple boots, moving the same files in or out of DCIM. I have not checked if different sizes, different distribution over directories etc have any impact.

With 3084 jpeg files, there were 3088 "object handles" visible through PTP, because PS.FI2, DCIM and the two image directories are also counted as PTP "objects"

The total size of all "objects" was 2,182,794,696 (a bit over 2^31, directories have 0 size in PTP)

SX160, using the same card, without CHDK enabled succeeds / fails on exactly the same number of images. (edit: Same for D10. SX710, which lists no limit in the manual, works with 3089 handles)

Removing the PS.FI2 allows one more jpeg, so it does appear to be based on "handles"
This matches the fact that USB connection (or the error) only happens after the camera finishes "indexing" the files and shows the total on the screen.

I wonder if we could make MetaCTG just stop counting when it hits the limit.
« Last Edit: 27 / October / 2021, 21:54:25 by reyalp »
Don't forget what the H stands for.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal