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

how to reboot cams in multicam setup?

  • 70 Replies
  • 11597 Views
*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to reboot cams in multicam setup?
« Reply #10 on: 16 / July / 2022, 06:28:29 »
Advertisements
To be more specific:
If you do !return chdku.rlibs:code({'multicam'})  does it print a whole bunch of code?

If you do !fsutil.writefile('test.txt','test') does it create a file named test.txt? If not, what happens if you use a full path to a directory you know you can write to?

like i wrote before, it was all on me. found the file, it was not in the chdkptp folder where i searched several times, but in home.

Quote
If the PC sends messages before the command completes, they are queued (in the camera side C code) until the script calls read_usb_msg again.

could it be that after a reboot there are still messages in memory? i know from experience that a reboot does not flush all memory like an off/on does. 
Quote
That implies that either the response to the 'tick' command was a boolean, or there was somehow a different, stale message waiting.
maybe you get more out of this file, no changes in multicam except the line printf added in init_sync_cam()
this time, it seemed to work for a few runs, you see the tick and status noted..however after a few tries it appears that the tick status for cam 2 is no longer tick, but rec and status true. note: cam 2 did go to record on that run.

strange that it appears to repeat itself, 2: true was already printed.

also, before this appears, there is a failed status with setclock on both cams before the tick is becoming a boolean, don't know if that might be related.
i'm going to change the code to see if it is related to the preshoot that came in too quick after a reboot and may have created a setclock failed status.
« Last Edit: 16 / July / 2022, 07:47:38 by Mlapse »
frustration is a key ingredient in progress

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to reboot cams in multicam setup?
« Reply #11 on: 16 / July / 2022, 08:58:06 »
the cam is just rebooting for the 10th time and i have not seen the problem of setclock or worse the boolean.
so although it appeared unlikely. it was my preshoot moment that crippled it..i made a delay for 10 seconds after boot and it works now.

getlastimg just gave me true...i was thinking of a path seeing  the function :haha
i should pick the second argument.....
   
time for diving into a download of the images after shoot in the interval

is there a way i can use getlastimg after each shot to download the latest images made?

i think deleting can be done in bulk just before reboot, but as discussed in some other post downloading in bulk takes up too much time in my setup.
something like: self:delete_files_list('A/DCIM') and then start the reboot sequence with move to play wait and reboot. or is that something that should be done when already in play?
or is it compulsory to delete the complete filenames and create dummy files that prevent crashes of the canon software, do i still need those if it is quickly followed by a reboot?

.....got a fresh mccam and will see if i can break that  ::)

« Last Edit: 16 / July / 2022, 15:02:57 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14098
Re: how to reboot cams in multicam setup?
« Reply #12 on: 16 / July / 2022, 20:08:53 »
like i wrote before, it was all on me. found the file, it was not in the chdkptp folder where i searched several times, but in home.
If you use a file function without a path, it uses the current working directory, which if you started the program from the terminal, would normally be the directory you were in when you ran the command.

Quote
could it be that after a reboot there are still messages in memory?
No, the data structures that hold them are initialized on boot, there is no way they could persist over reboots.

Quote
maybe you get more out of this file, no changes in multicam except the line printf added in init_sync_cam()
this time, it seemed to work for a few runs, you see the tick and status noted..however after a few tries it appears that the tick status for cam 2 is no longer tick, but rec and status true. note: cam 2 did go to record on that run.
In the log, you see
Code: [Select]
rec
1: true
2: true
1: {
 cmd="tick",
 status=31770
}
1: ticks=10 min=-6 max=2 mean=-1.771226 sd=2.598587
1: sends=10 min=1 max=4 mean=1.734219 sd=0.903129
2: {
 cmd="rec",
 status=true
}
So somehow, camera 2 got the status from 'rec' in response to the 'tick' command, despite already receiving status from both cams for 'rec' :blink:

I currently don't see how this could happen at all, let alone intermittently
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to reboot cams in multicam setup?
« Reply #13 on: 17 / July / 2022, 02:05:44 »
:blink:

I currently don't see how this could happen at all, let alone intermittently

won't happen again.  :-X

on an even brighter note, mccam starts without trouble after a header was added....not very functional though, but i'll work on that.

at the same time, getting something like 'download -nolua A/DCIM/100_0717/IMG_0001.JPG' work with getlastimg() and converted to work in multicam is still beyond me....or worse, it is already in there but i'm unable to see how or call it properly.
« Last Edit: 17 / July / 2022, 05:16:39 by Mlapse »
frustration is a key ingredient in progress


*

Offline reyalp

  • ******
  • 14098
Re: how to reboot cams in multicam setup?
« Reply #14 on: 17 / July / 2022, 19:01:50 »
on an even brighter note, mccam starts without trouble after a header was added....not very functional though, but i'll work on that.
One problem you may encounter is errors along the lines of "msg from unexpected script id". You may also get errors sending messages.

Each script started by chdkptp is given a unique ID, and messages are identified by which script generated them or expected to receive them. Various parts of the chdkptp code check that IDs match, because usually, seeing messages generated by a script other than the most recently started one is a sign of a problem.

Scripts started by on the camera (though the menu or using autostart) do not update the ID. For a script started with autostart, the ID will be zero, which is not a valid ID in the chdkptp code.

While it's possible to write chdkptp code that doesn't care about the script ID, the multicam code uses function that does, and I don't see a really straightforward way to work around it. The most straightforward would probably be to provide a way to set chdkptp's idea of the script ID to whatever is running on the camera, but this doesn't currently exist.

Quote
at the same time, getting something like 'download -nolua A/DCIM/100_0717/IMG_0001.JPG' work with getlastimg() and converted to work in multicam is still beyond me....or worse, it is already in there but i'm unable to see how or call it properly.
If you are running multicam, I'd suggest using mc:download_images. To download the most recent image, you could use
Code: [Select]
mc:download_images{lastimg=1}
lastimg=N is the number of images, starting from the current file counter value, so lastimg=5 should get the 5 most recent images. Not it's possible there are corner cases when the file counter wraps past 9999 or the folder changes.

Other filtering options are generally the same as what is available from the imdl CLI command. You can look at cli.lua to see how these map to options passed in the opts array to download_images.

Or if you want to get the paths and handling downloading yourself, you can use mc:imglist which takes the same options and returns table of file information indexed by camera id.
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to reboot cams in multicam setup?
« Reply #15 on: 18 / July / 2022, 02:06:14 »
While it's possible to write chdkptp code that doesn't care about the script ID, the multicam code uses function that does, and I don't see a really straightforward way to work around it. The most straightforward would probably be to provide a way to set chdkptp's idea of the script ID to whatever is running on the camera, but this doesn't currently exist.
i don't think that's the way i'm going, so don't think about it.
thanks you for the explanation, i was wondering why multicam didn't see them as equals.
Quote
If you are running multicam, I'd suggest using mc:download_images. To download the most recent image, you could use
Code: [Select]
mc:download_images{lastimg=1}
lastimg=N is the number of images, starting from the current file counter value, so lastimg=5 should get the 5 most recent images. Not it's possible there are corner cases when the file counter wraps past 9999 or the folder changes.
Or if you want to get the paths and handling downloading yourself, you can use mc:imglist which takes the same options and returns table of file information indexed by camera id.
hmm, i tried something similar, but got no download. i assumed it was because it needs to be in play for that kind of download.
while i want to download in between the shots during the interval.
will look at it again, maybe again thick fingers ;).
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14098
Re: how to reboot cams in multicam setup?
« Reply #16 on: 18 / July / 2022, 20:56:56 »
hmm, i tried something similar, but got no download. i assumed it was because it needs to be in play for that kind of download.
No, chdkptp download doesn't care if the camera is in rec. Some cameras have issues if you delete files in rec.

The download command -nolua option allows you to download while a script is running, unrelated to rec or play state. The actual download method is the same, it just skips some sanity checks and features that depend on script.
The multicam list/download functions talk to the multicam script, so they can use Lua while the script is running.

Quote
will look at it again, maybe again thick fingers
The verbose and pretend options may help understand what's going on if it doesn't behave as expected.
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to reboot cams in multicam setup?
« Reply #17 on: 19 / July / 2022, 04:31:08 »
Code: [Select]
              self:download_images{lastimg=1}
              self:download_images()

it works.
was hoping i could do os.remove('A/DCIM') after moving to play, but that didn't work, folders were still there after a reboot.
is this because it doesn't work if i have no dummy files in place for all images/files in the folders.
that makes it a bit tricky, i guess there is a way to use the option delete and replace of lastimg=1. but that would leave the folders...on the other hand, not a really big deal, the folders hardly take up space, but do eat at the max number files.


i've placed 4000 images on both cards.
as we know the cam states a communications error when booted with usb connected. and as a result multicam has both cams missing when started.
Since i'm not finished with the script i leave it for now. but this is really something i like to investigate.
« Last Edit: 19 / July / 2022, 12:59:47 by Mlapse »
frustration is a key ingredient in progress


*

Offline reyalp

  • ******
  • 14098
Re: how to reboot cams in multicam setup?
« Reply #18 on: 19 / July / 2022, 21:10:57 »
Code: [Select]
              self:download_images{lastimg=1}
              self:download_images()
it works.
I guess you're saying both work, but just to be sure self:download_images without options will download all images, while lastimg=1 should download only the most recent.

Quote
was hoping i could do os.remove('A/DCIM') after moving to play, but that didn't work, folders were still there after a reboot.
is this because it doesn't work if i have no dummy files in place for all images/files in the folders.
Behavior on non-empty may vary by camera model, but generally speaking, os.remove should only be used to remove empty directories. Attempting to remove non-empty may fail or result in filesystem corruption. To delete everything, you should individually delete all the files and sub-directories.

Quote
that makes it a bit tricky, i guess there is a way to use the option delete and replace of lastimg=1. but that would leave the folders...on the other hand, not a really big deal, the folders hardly take up space, but do eat at the max number files.
You can delete an arbitrary list of files/directories using mc:find_files and mc:delete_files_list. Like
Code: [Select]
files=mc:find_files('A/DCIM',{dirsfirst=false,ff_func='find_files_all_fn'})
mc:delete_files_list(files)
As usual, you can use pretend to see what it would do without actually deleting:
Code: [Select]
mc:delete_files_list(files,{pretend=true})
Quote
as we know the cam states a communications error when booted with usb connected. and as a result multicam has both cams missing when started.
Since i'm not finished with the script i leave it for now. but this is really something i like to investigate.
I could be wrong, but I suspect there isn't an easy way to avoid the "communication error" problem.
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to reboot cams in multicam setup?
« Reply #19 on: 20 / July / 2022, 01:28:51 »

I guess you're saying both work, but just to be sure self:download_images without options will download all images, while lastimg=1 should download only the most recent.

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.
can't tell you why i seem to find only peculiarities, but i'm willing to take the blame ;)
Quote
You can delete an arbitrary list of files/directories using mc:find_files and mc:delete_files_list. Like
Code: [Select]
files=mc:find_files('A/DCIM',{dirsfirst=false,ff_func='find_files_all_fn'})
mc:delete_files_list(files)
As usual, you can use pretend to see what it would do without actually deleting:
Code: [Select]
mc:delete_files_list(files,{pretend=true})
will test this.
Quote
I could be wrong, but I suspect there isn't an easy way to avoid the "communication error" problem.
I'm sure you are right  :D but want to pursue it nonetheless...after i finished this rollercoaster script...i meant, time lapse script

as i see it, one possible way could be to delete the CANONMSC folder before (re)boot/connection or when a new canon folder is created and then find a way to halt indexing f.i. by telling it there are only a few images on the card maybe: only 1 folder exists, rest is hidden. (i think the last folder would be best in that case) this way the cam does not know how many files are actually on the system and might accept a connection......
how and if this can be accomplished is a guess for me.

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.
« Last Edit: 20 / July / 2022, 04:08:31 by Mlapse »
frustration is a key ingredient in progress

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal