how to reboot cams in multicam setup? - page 3 - LUA Scripting - CHDK Forum

how to reboot cams in multicam setup?

  • 70 Replies
  • 14218 Views
*

Offline Caefix

  • *****
  • 948
  • Sorry, busy deleting test shots...
Re: how to reboot cams in multicam setup?
« Reply #20 on: 20 / July / 2022, 10:06:52 »
Advertisements
and another thought was, move (old) folders out of DCIM, so it won't be indexed. but that will probably lead to a lot of loose ends.

 :o ... https://chdk.setepontos.com/index.php?topic=14361.msg146217#msg146217
All lifetime is a loan from eternity.

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to reboot cams in multicam setup?
« Reply #21 on: 20 / July / 2022, 10:53:10 »
thanks caefix, already tried, so moving them is a NO.
what about saving them outside of DCIM in the first place? redirect the output location? Or redirect the indexing location? f.i. a folder called DCAM or DummyCIM

I've tested by placing 3 folders with a total of 5000 images on the sd card next to DCIM and the cam has no trouble connecting. files outside DCIM are not part of the max file number for ptp.
« Last Edit: 20 / July / 2022, 11:16:06 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14128
Re: how to reboot cams in multicam setup?
« Reply #22 on: 20 / July / 2022, 21:29:18 »
i wish i were, but i need both as i wrote them in the last post to get one file(set) per round downloaded. separately they do not work for me in the script.....
this first sets the option, the second does the download...at least that's how it appears to me.
Assuming you haven't modified the download_images function (or something it calls), I am extremely confident the first call is not somehow setting options for the second call. It's just not how any of those parts work at all.

For me, the first call alone works as expected, downloading one file per camera. If it doesn't work for you, I again suggest trying to understand what's actually happening.

As I mentioned before, you can add verbose=true to have it print each file downloaded, or pretend=true to print without actually downloading. download_images also returns the list it gathered, so in the console you can do like !return mc:download_images()

You can add additional print statements to check the steps from getting the list, to iterating over the cameras, to iterating over the files. To print a table like the file list, you can use print(util.serialize(list))

Quote
can't tell you why i seem to find only peculiarities, but i'm willing to take the blame ;)
It's not a matter of blame. You observe the code behaving in an unexpected way. That could be due to a bug in my code, or your code, or some other misunderstanding. Regardless, if you want to successfully build big, complicated scripts, you will be well served by taking the time to understand why something behaved unexpectedly.
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to reboot cams in multicam setup?
« Reply #23 on: 21 / July / 2022, 03:43:53 »
if i state something that i find strange, i do not understand, true there...for me, it's more that i'm making fun of myself for my lack of knowledge of how this works and what happens as a result.
i just need time to process what i see happening before i can come up with a solution.
and, for me, talking or writing about it helps me organize my thoughts and might give me useful feedback....as been proven many times.

what appeared to happen was that the reboot that is called from the pc, but processed and executed cam side came in too early after download_images{lastimg=1}....it's no cmdwait.
so i added a 5 sec. sleep because i thought as much, with the idea that 5 seconds was wildly more time than needed to download a set of images from the cam....was expecting that to be closer to 1 second than 5.
but, it was apparently not enough to complete this download before the pc called a reboot and the cam started with it's own cycle of moving to play and sleeping until reboot.

when i accidentally removed the quotes from download_images() without adding them to download_images{lastimg=1} for another test. it suddenly worked! it finished to download lastimg before the cam side reboot was executed....and as before did not finish the last instruction: this time, download_images(). so that's when i posted the weirdly looking but working code.

by now it's working normally, so shots are taken, images are downloaded, files are deleted.
as long as i don't use the reboot. i'll have to see how i can adapt the reboot to work without fuss....or how much sleep is needed after the lastimg download to make it work.

and nice, just got some new, quality usb cables in with 90 degrees mini-usb connectors... much better in my setup.
« Last Edit: 21 / July / 2022, 06:58:31 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14128
Re: how to reboot cams in multicam setup?
« Reply #24 on: 21 / July / 2022, 23:38:39 »
i just need time to process what i see happening before i can come up with a solution.
and, for me, talking or writing about it helps me organize my thoughts and might give me useful feedback....as been proven many times.
Completely agree with that.  Even if I get frustrated sometimes, I don't mean to discourage you from posting. But if it behaves in some weird, unexpected way, I'm a lot more likely to be able to help if you can identify specifically where the behavior goes weird... and in the process of narrowing it down, you may discover the cause yourself.
Quote
what appeared to happen was that the reboot that is called from the pc, but processed and executed cam side came in too early after download_images{lastimg=1}....it's no cmdwait.
I'm not clear exactly what you've observed or what your current code looks like, but if you're saying a reboot after download_images prevents the download from working, I am 100% certain this cannot be correct (unless there's like a syntax error that prevents it from running at all, but that should be obvious). download_images downloads each file sequentially with a download call, it can only finish when the downloads are done or an error occurs.

If you're doing the download after the reboot, you obviously need to wait for the reboot to be done, but if you didn't, it should fail with some specific error message related to the connection or script.

Again, if you aren't sure things are actually being called or what order, it's helpful to throw in some print statements to confirm.
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to reboot cams in multicam setup?
« Reply #25 on: 22 / July / 2022, 02:02:41 »
Quote
if you're saying a reboot after download_images prevents the download from working, I am 100% certain this cannot be correct
well, don't know what to say, because in that case i'm still in the dark about what happened despite using print, verbose or pretend statements.
because i'm planning to change the reboot call so it won't interfere.....and if it doesn't i'm solving nothing.

what i made is so full of tries and comments...
this is a more or less cleaned up part of the code:

as is, it works: lastimg downloaded followed by a reboot
if i remove one of the self:download_images it does not work anymore. (no download is done before cam reboots)
if i remove one of the self:download_images AND reboot_cam it works (download either of one file or of all files is done, no reboot..this is my solution now)
fyi reboot_cam refers to the cam side reboot sequence of: go to play -> sleep ->reboot

if you really want i can share the multicam script as it was close to that point, but it's awfull messy and very hard to read...you might even think that now with all those unrelated print statements.

Code: [Select]
            if currenttime>=next_shot_moment then
                next_shot_moment=math.floor((currenttime+secs)/secs)*secs
                self:cmdwait('shoot')
                printf('interval: %s now: %s next shot: %s\n',secs,currenttime,next_shot_moment)
                imagenr=math.floor((currenttime-(math.floor(currenttime/86400)*86400))/secs)+math.floor(60*(60/secs))
                if imagenr>(86400/secs) then imagenr=math.floor(imagenr-(86400/secs)) end
                printf('%s: next image %s\n',secs,imagenr)
                printf('image shot %s \n',self:cmd('getlastimg'))
              self:download_images{lastimg=1}
              self:download_images()
                t2=5
                repeat
            t2=t2-1
                    sys.sleep(1000)
                until t2==0
                loop=0
                self:cmd('reboot_cam')


« Last Edit: 22 / July / 2022, 03:58:29 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14128
Re: how to reboot cams in multicam setup?
« Reply #26 on: 22 / July / 2022, 23:28:21 »
well, don't know what to say, because in that case i'm still in the dark about what happened despite using print, verbose or pretend statements.
Those steps should have at least narrowed down the possible points at which it starts misbehaving, but I can't help without knowing something about what the results were.

For example, you have two calls to download_images. Either the first one attempts to download files, or it does not. You should be able to definitively determine which is true. 

When verbose is set, download_images should output a line for each file that would be downloaded, like:
A/DCIM/100_CANON/IMG_1234.JPG->01/100_CANON/IMG_1234.JPG

If it does, and the destination file does not exist after the call, then you know con_methods:download_file_ff is either not calling self:download or the call is somehow failing.

If it does not print anything, then either con_methods:download_file_ff isn't being reached, or the option isn't getting passed through. You should again be able to definitively identify which is true with a few print statements:
Code: [Select]
local list=self:imglist(opts)
gets a list of images from each camera. Either 'list' above contains tables of file information for the expected files, organized by camera, or it does not.

Moving on, it iterates over the cameras
Code: [Select]
for id,imgs in pairs(list) do
and the files for each camera
Code: [Select]
for i,f in ipairs(imgs) do
and finally attempts to download them
Code: [Select]
lcon:download_file_ff(f,dst,opts)

So you can ask
1) Is it getting the correct list
2) Is it iterating over the cameras and files returned in the list
4) If it reaches the lcon:download_file_ff(f,dst,opts) are the expected arguments passed
5) Does chdku.lua con_methods:download_file_ff reach the self:download call?

Each of these are small questions, which you should be able to definitively answer with simple print statements.
I can't predict what the answers will be, but if you get the answers, I might be able to suggest where to look next.
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to reboot cams in multicam setup?
« Reply #27 on: 26 / July / 2022, 15:38:06 »
i should have answers by now, and i got a few but got more in return.

i assumed that if i removed the file after it was copied it would save time around the reboot.
to organize the pictures i always set them in the canon software to reset the image counter with a new folder.

when using delete_files_list the cam does not reboot yet, it stays off...so i was trying different things without success to solve this halted reboot and then i realized.

it will never work like this because my assumption was off and that meant that after a (re)boot the files were skipped in copying (but still deleted) because the same numbered files already existed  :haha
..should have thought of that without trying...or reboot exactly at 00:00

now i have no idea how to proceed, is there a way i can copy the files without loosing to much downtime? what would be the proper approach?
since i have to reboot daily to not exceed the ptp file limit they have to be deleted at some point without breaking the reboot.

Code: [Select]
                 self:cmdwait('shoot')
                 self:download_images{lastimg=1}
--                  files=self:find_files('A/DCIM',{dirsfirst=false,ff_func='find_files_all_fn'})
--                  self:delete_files_list(files)


« Last Edit: 26 / July / 2022, 16:12:26 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14128
Re: how to reboot cams in multicam setup?
« Reply #28 on: 26 / July / 2022, 20:51:19 »
to organize the pictures i always set them in the canon software to reset the image counter with a new folder.
FWIW download_images provides extensive controls for naming the files, using the "subst strings" documented for imdl or variables defined in your own code, so you could organize them at download time rather than trying to keep the camera counter in sync.

Note using CHDK reboot may cause the Canon image counter to not be saved, and that the Canon firmware may reset the counter based on the highest numbered image found on the card.

Quote
when using delete_files_list the cam does not reboot yet, it stays off...
By "it stays off" do you mean the camera crashes? If this the case, and you are using the code posted below, it's likely that it's caused by not switching to playback before deleting.

If there's a lot of images, the camera may spend quite a bit of time "indexing" when you switch to play.

Note the deleting bug applies to CHDK delete (and remoteshoot). Some alternatives are discussed in https://chdk.setepontos.com/index.php?topic=14302.msg147265#msg147265 and https://chdk.setepontos.com/index.php?topic=11481.msg146783#msg146783

Quote
it will never work like this because my assumption was off and that meant that after a (re)boot the files were skipped in copying (but still deleted) because the same numbered files already existed  :haha
..should have thought of that without trying...or reboot exactly at 00:00

now i have no idea how to proceed, is there a way i can copy the files without loosing to much downtime? what would be the proper approach?
I'm sorry, I don't follow at all what the plan was, or why it would not work.

Quote
now i have no idea how to proceed, is there a way i can copy the files without loosing to much downtime? what would be the proper approach?
since i have to reboot daily to not exceed the ptp file limit they have to be deleted at some point without breaking the reboot.
If the problem is the crash mentioned above, the simple approach is to switch to play, delete, and then reboot. If that causes too much delay, then maybe the PT_EraseAllFile approach might be another option.
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to reboot cams in multicam setup?
« Reply #29 on: 27 / July / 2022, 01:58:02 »
FWIW download_images provides extensive controls for naming the files, using the "subst strings" documented for imdl or variables defined in your own code, so you could organize them at download time rather than trying to keep the camera counter in sync.

Note using CHDK reboot may cause the Canon image counter to not be saved, and that the Canon firmware may reset the counter based on the highest numbered image found on the card.

i have to give that renumbering some thought, i made a calculation based on time: at this moment the pc side script already calculates the number an image 'should' have and that might be used when downloading to rename it......have to add IMG_ to it, enough 0 to make up 4 digits and figure out how to use it in download_images{lastimg=1} while keeping the folder dates from the cam.

because the cams work with utc+1, but the pc is changing from summer to wintertime and i don't want that hour ending up in the wrong folder.

otherwise i guess it has to become something like :
download_images{lastimg=1} [${subdir}/${dlseq}]
and that will probably lead close to the same numbering.

and maybe you just handed another option although implementing it might prove difficult:
delete all images but the last, so that last image is still there at reboot, keeping the image counter correct

Quote
By "it stays off" do you mean the camera crashes? If this the case, and you are using the code posted below, it's likely that it's caused by not switching to playback before deleting.

If there's a lot of images, the camera may spend quite a bit of time "indexing" when you switch to play.

Note the deleting bug applies to CHDK delete (and remoteshoot). Some alternatives are discussed in https://chdk.setepontos.com/index.php?topic=14302.msg147265#msg147265 and https://chdk.setepontos.com/index.php?topic=11481.msg146783#msg146783

I think i do, but it's not a hard crash.....don't have to pull the battery, it works again with pressing the [on] button.
 
and although indexing takes up a lot of time. i have not seen that as a problem when rebooting from SUIx after 3 weeks and at that moment some 60.000 images on card.
it just reboots without waiting the indexing to finish and never had trouble with that.
did have some trouble, but that was the indexing when it starts up again. (busy)
so i would not expect it to become an issue with multicam ordering the reboot.

the sequence of shooting, downloading and removing works in record, move to play seems to work and reboot stops after powering down and the screen turns black, i can either remove the reboot or the delete sequence and the script will keep running..........will look more in depth at those alternatives.

Quote
If the problem is the crash mentioned above, the simple approach is to switch to play, delete, and then reboot.
wanted to try that, will test if that does not halt the reboot..it doesn't.
however i did see 'image too large' with a question mark on one of the cams when in play...it appears before the reboot happens and i've only seen it on rev 102b cam, not on the 103a and it does not happen every time.
it does not seem to hinder the reboot, so time to look into that numbering sequence, because after 10 reboots i still only have 2 cams of img_0001.jpg downloaded and cam side they are gone.
Quote
If that causes too much delay, then maybe the PT_EraseAllFile approach might be another option.
if i have to wait for indexing to finish before i use delete. and for now it looks like that need is not there.
and to see if delete_files itself takes up much time, i have to test with more images.
EraseAllFile, i don't know this one...what i read so far, makes me believe it is cam model specific to make it work and for that reason should be avoided by me if at all possible.

it will take a few more tweaks to the script, like the file numbering, before i can do a proper test where it will reboot once a day for a week to see how much time is involved in deleting a days worth of images and rebooting is complete.
« Last Edit: 27 / July / 2022, 15:07:05 by Mlapse »
frustration is a key ingredient in progress

 

Related Topics


SimplePortal © 2008-2014, SimplePortal