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

how to reboot cams in multicam setup?

  • 70 Replies
  • 11628 Views
*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to reboot cams in multicam setup?
« Reply #30 on: 28 / July / 2022, 02:51:09 »
Advertisements
tried to make it work and looking at usage.txt i couldn't get my calculated imagenr used.
i probably should catch that in ${imgnum} but to me it is unclear how to do that.

Code: [Select]
${imgpfx}${imagenr}${ext}.
unknown substitution function
i made a run with only one shot per reboot to test if i could get the syntax right.

then i tried dlseq and when that did not work, shotseq as i thought it would be the solution to numbering shot files from 1 onwards starting each new camera day (or cam side folder).

if i had to guess not working means dlseq uses the cam side numbering.
i'm still stuck with img_0001.jpg and next files are skipped since having the same number.


Code: [Select]
self:download_images({lastimg=1, dst='${id}/${subdir}/${dlseq}'})

i guess it isn't this hard if you know what you are doing ;)
« Last Edit: 28 / July / 2022, 07:02:29 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14098
Re: how to reboot cams in multicam setup?
« Reply #31 on: 28 / July / 2022, 19:01:28 »
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.
FWIW, you can get UTC (not UTC+1, sorry) by putting ! at the start of the date sub strings, as documented for os.date.

Quote
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.
Normally a "crash" in CHDK means the camera records a romlog (to internal flash memory), and then shuts down. Again, if you get the romlog I can confirm whether it is the file delete crash or something else.

Quote
wanted to try that, will test if that does not halt the reboot..it doesn't.
I'm sorry, I don't understand what outcome you are describing here. Do you mean that switching to play before deleting avoids the crash, or not?

Quote
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's normal to see something like unknown or invalid image after deleting using CHDK.

tried to make it work and looking at usage.txt i couldn't get my calculated imagenr used.
i probably should catch that in ${imgnum} but to me it is unclear how to do that.

Code: [Select]
${imgpfx}${imagenr}${ext}.
unknown substitution function
The names in ${whatever} need to be defined in the code, you can't just add new names like imagenr without implementing a new subst function (see download_images_subst_funcs) .  I thought I posted more details of this, not sure if I messed up or or the forum ate something :blink:

Anyway, if you have the number you want to use in a variable named my_image_number, you can do something like
Code: [Select]
dst='${id}/${subdir}/IMG_'..string.format('%04d',my_image_number)..'${ext}'
Note that this value would be used for every image downloaded by that download_images call, unlike the subst values which can vary per image. So if you download multiple images with one call, you'd need something else to ensure the names were unique.

Quote
then i tried dlseq and when that did not work, shotseq as i thought it would be the solution to numbering shot files from 1 onwards starting each new camera day (or cam side folder).

if i had to guess not working means dlseq uses the cam side numbering.
i'm still stuck with img_0001.jpg and next files are skipped since having the same number.
shotseq and dlseq are unfortunately special in multicam download_images. The initial value for the call is set by the dlseq_start and shotseq_start options passed to download_images, which default to 1. Note the value starts at the initial value for each camera. So if you shot ten shots, you will get images numbered 1 to 10 for each camera.

This also means shotseq / dlseq values are not preserved between calls (unlike imdl). In the example above, if you shot another ten images and downloaded again, the images would be numbered 1 to 10 again. So if you want to do sequential numbers over multiple download calls, you'd need to track that yourself somehow.
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to reboot cams in multicam setup?
« Reply #32 on: 29 / July / 2022, 01:33:58 »
Normally a "crash" in CHDK means the camera records a romlog (to internal flash memory), and then shuts down. Again, if you get the romlog I can confirm whether it is the file delete crash or something else.
i do not look at the card after each failed test, just change code and try again. there is no romlog on it at the moment.
Quote
I'm sorry, I don't understand what outcome you are describing here. Do you mean that switching to play before deleting avoids the crash, or not?
It's normal to see something like unknown or invalid image after deleting using CHDK.
yes, moving to play before deleting files makes delete files and then reboot work.

Quote
The names in ${whatever} need to be defined in the code, you can't just add new names like imagenr without implementing a new subst function (see download_images_subst_funcs) .  I thought I posted more details of this, not sure if I messed up or or the forum ate something :blink:
it was unclear to me how to define that or make imgnum = imagenr. and thought that the crippled code would at least show you what i was thinking of.
Quote
Anyway, if you have the number you want to use in a variable named my_image_number, you can do something like
Code: [Select]
dst='${id}/${subdir}/IMG_'..string.format('%04d',my_image_number)..'${ext}'
Note that this value would be used for every image downloaded by that download_images call, unlike the subst values which can vary per image. So if you download multiple images with one call, you'd need something else to ensure the names were unique.
this works for me.
but i'll remember for when i get to the point that i want to download more than one image between shots...something that, at this point, is still far beyond the horizon.
Quote
shotseq and dlseq are unfortunately special in multicam download_images. The initial value for the call is set by the dlseq_start and shotseq_start options passed to download_images, which default to 1. Note the value starts at the initial value for each camera. So if you shot ten shots, you will get images numbered 1 to 10 for each camera.

This also means shotseq / dlseq values are not preserved between calls (unlike imdl). In the example above, if you shot another ten images and downloaded again, the images would be numbered 1 to 10 again. So if you want to do sequential numbers over multiple download calls, you'd need to track that yourself somehow.
that's not unfortunate, it's a great numbering method, just not for me.
i created imagenr just making sure i always had the 'correct' sequential number for my purpose and in the current setup it works.

i changed reboot sequence to 15 minutes for the next tests.
after reboot #3 it had an i/o error after moving to play and files were not removed.
restarting the script resulted again in an i/o error after moving to play at some moment and files were again not removed.
it is every time cam #1 with the 102b revision, not cam #2 with the 103a..even if i swap usb ports.
i added a delay before it starts removing that seems to have solved it, maybe it's just too close to the 'go to play' that the canon software is not ready yet.
although i would think the cmdwait('play') would give enough time for the canon software to be ready.

and after running close to an hour i've seen 4 lines of
'attempting to close non present device'
between 2 shots.
must have happened during lastimg download. no idea what caused it or why it was resolved. but i stopped the script a few shots later, so i have to check if it repeats itself.

before i start rewriting it to something more functional and readable that doesn't work long term.
i think it's time to put it in a daily reboot sequence to see if it works stable and how
 long the reboot will take when it removes a day worth of images.

« Last Edit: 29 / July / 2022, 05:42:25 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14098
Re: how to reboot cams in multicam setup?
« Reply #33 on: 29 / July / 2022, 21:05:53 »
i do not look at the card after each failed test, just change code and try again. there is no romlog on it at the moment.
When the camera crashes, the log is saved to onboard flash (the "ROM" that contains the firmware). To get the log to a file, you should use the Debug menu ""Save ROM crash log" option.

But...
Quote
yes, moving to play before deleting files makes delete files and then reboot work.
is probably enough confirmation without the romlog.

Quote
i changed reboot sequence to 15 minutes for the next tests.
after reboot #3 it had an i/o error after moving to play and files were not removed.
restarting the script resulted again in an i/o error after moving to play at some moment and files were again not removed.
Did the camera crash? This is the most common cause of IO error, and if so, get the romlog.

Quote
it is every time cam #1 with the 102b revision, not cam #2 with the 103a..even if i swap usb ports.
It's not impossible, but I would be quite surprised if it is related to Canon firmware rev.

Quote
i added a delay before it starts removing that seems to have solved it, maybe it's just too close to the 'go to play' that the canon software is not ready yet.
although i would think the cmdwait('play') would give enough time for the canon software to be ready.
I wouldn't be surprised if some additional delay is required.

Quote
and after running close to an hour i've seen 4 lines of
'attempting to close non present device'
between 2 shots.
This message means chdkptp went to close a connection, but the USB device associated with it is no longer known to the OS. This normally happens if the camera is shut down or crashes, and then you call disconnect or quit chdkptp without calling con:is_connected()

The message may appear a significant time after the camera went away, since connections are closed when they are garbage collected. It's common to see this when you exit chdkptp.

The message itself harmless, but you might want to double check that your reboot sequence cleanly disconnects before the camera actually reboots.
Don't forget what the H stands for.


*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to reboot cams in multicam setup?
« Reply #34 on: 30 / July / 2022, 02:25:29 »
Did the camera crash? This is the most common cause of IO error, and if so, get the romlog.
system sleep solved it.
Quote
It's not impossible, but I would be quite surprised if it is related to Canon firmware rev.
i had this thought too, but after some delays here and there i think it is because chdkptp starts with cam one, so if there is not enough delay the first one gets it.
Quote
I wouldn't be surprised if some additional delay is required.
i hope i've added enough by now

Quote
This message means chdkptp went to close a connection, but the USB device associated with it is no longer known to the OS. This normally happens if the camera is shut down or crashes, and then you call disconnect or quit chdkptp without calling con:is_connected()

The message may appear a significant time after the camera went away, since connections are closed when they are garbage collected. It's common to see this when you exit chdkptp.

The message itself harmless, but you might want to double check that your reboot sequence cleanly disconnects before the camera actually reboots.
this message is between 2 shots, no reboot. and by now i've seen it a few times.

after those lines the cam has not crashed (yet) but goes on shooting...i added another delay to hopefully prevent this (still untested)
« Last Edit: 30 / July / 2022, 05:24:20 by Mlapse »
frustration is a key ingredient in progress

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to reboot cams in multicam setup?
« Reply #35 on: 02 / August / 2022, 03:46:13 »
trying to run the setup with one reboot a day hasn't been succesfull this far

although a >1 sec sleep between the shoot and download improved stability (no more non present device warning, by now sleep is 3 seconds), i'm still getting an occasional i/o error between shots at approx the same moment i first got the non present device warning.


it happens during self:download_images({lastimg=1, dst=', somewhere just after line
1342 -- list all cams
and before line
1353 subst.state._seq_first_done = false -- state is re-used for multiple cams

but the print statement "missing connection" is not printed, it just states 2 errors: call failed:I/O error and error on line 7 and the script stops...although one cams stays active, the failing one will shut down with lens extended. and once in 10 both cams stay active.

Code: [Select]
local list=self:imglist(opts)
this one is not completed and kills one cam as far as i narrowed it down. if it does continue, you see that it takes a lot of time to do the next 'for' loop..but that could be normal.

it can run for as little as 30 minutes before this happens or it can take up to 8 hours i've found no pattern, other than: it happens less with a delay between shoot and download.
btw, by now finally cam #2 gave out first..so my theory that it starts with cam #1 and thus it is the one that fails if something comes in too quick is disproven.

still happened after half a day, so i made it 5 seconds now...what i think is strange is that if i let the cmdwait of shoot time out seconds earlyer than the sleep for download takes, the I/O error does not happen more often, if i remove the sleep it does. and 5 seconds sleep failed withing a few minutes. so that isn't it either.
i've slowed down the whole loop, still testing.

what i do see is that imglist is most of the times instantly and on other moments it takes up to a few seconds to complete
« Last Edit: 02 / August / 2022, 16:03:23 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14098
Re: how to reboot cams in multicam setup?
« Reply #36 on: 02 / August / 2022, 21:03:06 »
but the print statement "missing connection" is not printed, it just states 2 errors: call failed:I/O error and error on line 7 and the script stops...although one cams stays active, the failing one will shut down with lens extended.
This sounds like one of the cameras crashed. You should get the romlog and post it here.

Quote
Code: [Select]
local list=self:imglist(opts)
If you think it's crashing in that call, you can confirm by putting prints before and after like
Code: [Select]
print('listing images')
local list=self:imglist(opts)
print('done')
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to reboot cams in multicam setup?
« Reply #37 on: 03 / August / 2022, 02:41:55 »
it's was already in a new run....by now the whole script looks like it's made in a padded room with 'sleep' written on every wall :)
but didn't stop the i/o error....around 3 hours of run time before it happened.
again during self:imglist(opts)

while this is irrelevant if i can't solve the i/o error, i thought i'd ask anyway.
if i use self:download_images() and there are no files to copy i get a warning.
is there a way to check if there are files in dcim before i use download_images()?
or should i just accept the warning since it appears to make no difference in the running script.
« Last Edit: 03 / August / 2022, 03:04:51 by Mlapse »
frustration is a key ingredient in progress


*

Offline reyalp

  • ******
  • 14098
Re: how to reboot cams in multicam setup?
« Reply #38 on: 04 / August / 2022, 00:36:03 »
it's was already in a new run....by now the whole script looks like it's made in a padded room with 'sleep' written on every wall :)
but didn't stop the i/o error....around 3 hours of run time before it happened.
again during self:imglist(opts)
IO error is just chdkptp trying to talk to a camera that crashed.

Do you know the Canon firmware version of the camera that log came from?

Anyway the crash in the log was
Quote
ASSERT!! ChaseFrame.c Line 272
Occured Time  2022:08:03 07:52:01
Task ID: 28704830
Task name: MotionVector0
It seems strange that this crash would be associated with getting the file list, but it's possible the camera actually crashes at some other point, and chdkptp doesn't notice until it tries to get the file list. If you can post the whole file you are using, that would help me understand.

A very similar crash was seen with the s100 port, and was found to be related to the remotehook placement (https://chdk.setepontos.com/index.php?topic=7887.msg114536#msg114536 fix in https://chdk.setepontos.com/index.php?topic=7887.msg114622#msg114622).

Even though it appears to be the same assert, it's not clear the cause is the same. The s100 crash was found while using the USB remote. multicam does does the remote hook while shooting in some cases, so it could plausibly be the same, if the actual crash is tied to shooting. I'll look into applying the same change to the s110 port.

The same assert was also reported on elph300hs https://chdk.setepontos.com/index.php?topic=6341.msg92931#msg92931
Quote
if i use self:download_images() and there are no files to copy i get a warning.
is there a way to check if there are files in dcim before i use download_images()?
or should i just accept the warning since it appears to make no difference in the running script.
Looks like ff_imglist doesn't account for DCIM is missing (or the current subfolder, if using lastimg). That's a bug I should fix, but I think it's probably safe to ignore the warning. Unless something breaks after it happens  ;)
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to reboot cams in multicam setup?
« Reply #39 on: 04 / August / 2022, 03:28:13 »
Do you know the Canon firmware version of the camera that log came from?
this was the s110-103a as cam #1, but it happens too if it is cam #2 and the s110-102b has the same halt on imglist.

Quote
It seems strange that this crash would be associated with getting the file list, but it's possible the camera actually crashes at some other point, and chdkptp doesn't notice until it tries to get the file list. If you can post the whole file you are using, that would help me understand.
it makes a picture just before that so it might be shooting related, i made a 1 sec sleep before download and 6 sec after, since it seemed to help prevent i/0 errors. else not much going on.
for your understanding, i tried to clean the code and comments up a bit...if it is still too messy to understand, ask me. and if you want to improve or add something, feel free :)

Quote
A very similar crash was seen with the s100 port, and was found to be related to the remotehook placement (https://chdk.setepontos.com/index.php?topic=7887.msg114536#msg114536 fix in https://chdk.setepontos.com/index.php?topic=7887.msg114622#msg114622).

Even though it appears to be the same assert, it's not clear the cause is the same. The s100 crash was found while using the USB remote. multicam does does the remote hook while shooting in some cases, so it could plausibly be the same, if the actual crash is tied to shooting. I'll look into applying the same change to the s110 port.

The same assert was also reported on elph300hs https://chdk.setepontos.com/index.php?topic=6341.msg92931#msg92931

it is ashame that i only have one s100 and not a set, otherwise i would now try to see if they would develop the same i/o error.

Quote
Looks like ff_imglist doesn't account for DCIM is missing (or the current subfolder, if using lastimg). That's a bug I should fix, but I think it's probably safe to ignore the warning. Unless something breaks after it happens  ;)
it is not for using lastimg, it is for when the pc connects fresh and there are images on the card: (possibly not downloaded & hard to check if they were since they are renamed when downloaded with lastimg) 
my idea was: download them as is in a separate folder, delete and reboot before it starts the interval since max file number might become a problem if there are still images on the card.


and i noticed this before, do you use a script to harvest all the lua files posted on this website or is that an external bot?
« Last Edit: 04 / August / 2022, 07:55:16 by Mlapse »
frustration is a key ingredient in progress

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal