Change timeout time for usb_sync_wait - page 2 - General Help and Assistance on using CHDK stable releases - CHDK Forum

Change timeout time for usb_sync_wait

  • 20 Replies
  • 458 Views
Re: Change timeout time for usb_sync_wait
« Reply #10 on: 27 / March / 2019, 11:23:14 »
Advertisements

From your description, it sounds like the easiest way to do this would be to have your PC monitor the trigger signal, issue commands over a USB connection for all cameras to shoot, and then upload the images from each camera.  No USB remote hardware cables required - simply enough USB hub connections to provide one cable per camera.  All you need then is some I/O device for your PC to accept the signal.

I also have already thought about this way. But my problem was to merge the pc monitored signal with my chdkptp console.
I open the chdkptp with "chdkptp.exe -i" in a .bat file in command mode. Here I run some commands in loops from .txt files with "source xxx.txt".
But how can I run some commands automaticaly in depence of the monitored signal?

Re: Change timeout time for usb_sync_wait
« Reply #11 on: 27 / March / 2019, 11:42:48 »
I also have already thought about this way. But my problem was to merge the pc monitored signal with my chdkptp console. I open the chdkptp with "chdkptp.exe -i" in a .bat file in command mode. Here I run some commands in loops from .txt files with "source xxx.txt".
But how can I run some commands automaticaly in depence of the monitored signal?
I'll ask @reyalp to answer that one. From what I understand, you can run a Lua script on your PC under chdkptp.exe.  The script code to use CHDK commands to control the cameras via PTP is straight forward in that case. The trick will be getting Lua to read some PC I/O device that's monitoring your trigger signal.

If it was me, I might try hacking a USB mouse button to the trigger signal and then check for mouse events from the Lua script.  I'm sure there is a better way though.  When I did my photobooth project, I ran chdkptp on a Raspberry Pi so monitoring a digital signal via the Pi's I/O was very easy.  I actually wrote the main loop in C and had it issue individual commands over ptp by running individual instances for chdkptp for each command.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Change timeout time for usb_sync_wait
« Reply #12 on: 27 / March / 2019, 11:53:52 »

If it was me, I might try hacking a USB mouse button to the trigger signal and then check for mouse events from the Lua script.  I'm sure there is a better way though.  When I did my photobooth project, I ran chdkptp on a Raspberry Pi so monitoring a digital signal via the Pi's I/O was very easy.  I actually wrote the main loop in C and had it issue individual commands over ptp by running individual instances for chdkptp for each command.

I found a function, I could use a to the pc connected Arduino simulating a mouse click. With tis i could track digital signals very easy and produce mouse clicks. Run chdkptp on Rasperry is no option for me. I need a normal computer. How can I check for mouse events from the Lua script?

If this would be possible I hopefully have all parts of my puzzle.

*

Offline reyalp

  • ******
  • 11900
Re: Change timeout time for usb_sync_wait
« Reply #13 on: 27 / March / 2019, 14:23:50 »
How can I check for mouse events from the Lua script?
Rather than using a mouse click, can you run some external program that waits for the signal? If you, can either use os.execute() or chdkptp fstutil.popen() if you want to read the programs output.

So in your lua code, something like
Code: [Select]
local status, exit_type, ret = os.execute('wait_for_shoot_signal.exe')
if status and exit_type == 'exit' and ret == 0 then
 mc:shoot({... shoot params ... })
end
This assumes you provide wait_for_shoot_signal.exe which monitors your hardware and returns success (0) when the signal arrives. You could have it return a different value if you want to cancel the shot.

Note if you want lower latency, you should do preshoot before waiting for the program and then just send the shoot command to trigger.  This could by modifying (a copy of) multicam.lua mc:shoot() with the os.execute stuff inserted after
Code: [Select]
self:print_cmd_status_short(self:cmdwait('preshoot'))
edit:
If you need better sync and latency, multicam.lua also supports another method using the hardware remote: the remote_on_wait option.

With this option, after you do shoot, the script set up the shot and wait in the remote hook for the USB +5 to go high. When it does, shooting will proceed to the hardware remote hook, which waits for it go low.
The timeout for script wait can be controlled with remote_on_wait and can be arbitrarily long.
« Last Edit: 27 / March / 2019, 14:32:50 by reyalp »
Don't forget what the H stands for.


Re: Change timeout time for usb_sync_wait
« Reply #14 on: 04 / April / 2019, 09:05:40 »
Code: [Select]
local status, exit_type, ret = os.execute('wait_for_shoot_signal.exe')
if status and exit_type == 'exit' and ret == 0 then
 mc:shoot({... shoot params ... })
end
This assumes you provide wait_for_shoot_signal.exe which monitors your hardware and returns success (0) when the signal arrives. You could have it return a different value if you want to cancel the shot.

Thanks a lot for this!
I wrote a small Skript and made an .exe out of it. If I use the lua code with my .exe the variables , status, exit_code and ret are nil. I tried different things to get a return here. How can I get a return in case the .exe exits? An dstore this info into a variable?
« Last Edit: 04 / April / 2019, 09:08:56 by R.Blickle »

Re: Change timeout time for usb_sync_wait
« Reply #15 on: 04 / April / 2019, 09:11:14 »
Code: [Select]
local status, exit_type, ret = os.execute('wait_for_shoot_signal.exe')
if status and exit_type == 'exit' and ret == 0 then
 mc:shoot({... shoot params ... })
end
This assumes you provide wait_for_shoot_signal.exe which monitors your hardware and returns success (0) when the signal arrives. You could have it return a different value if you want to cancel the shot.

Thanks a lot for this!
I wrote a small Skript and made an .exe out of it. If I use the lua code with my .exe the variables , status, exit_code and ret are nil. I tried different things to get a return here. How can I get a return in case the .exe exits? And store this info into a variable?

*

Offline reyalp

  • ******
  • 11900
Re: Change timeout time for usb_sync_wait
« Reply #16 on: 04 / April / 2019, 13:55:13 »
Thanks a lot for this!
I wrote a small Skript and made an .exe out of it. If I use the lua code with my .exe the variables , status, exit_code and ret are nil. I tried different things to get a return here. How can I get a return in case the .exe exits? An dstore this info into a variable?
What is the script you "made an .exe out of" ?
Normally an .exe would be a windows executable, but you could use a batch file or any other program you can run from the command line with os.execute. If you are not using windows, then a shell script or native executable would be fine too.

Quote
if I use the lua code with my .exe the variables , status, exit_code and ret are nil. I tried different things to get a return here.
Can you show the code you are using? The only reason I can think all would be nil is if you are trying to access them outside the scope of the local, like if you are doing each line with ! commands.

FWIW, the suggestion I added in edit ( remote_on_wait ) might be a better solution for you, I didn't remember that feature until after I wrote the first part.
Don't forget what the H stands for.

Re: Change timeout time for usb_sync_wait
« Reply #17 on: 05 / April / 2019, 02:23:11 »

What is the script you "made an .exe out of" ?
Normally an .exe would be a windows executable, but you could use a batch file or any other program you can run from the command line with os.execute. If you are not using windows, then a shell script or native executable would be fine too.


I wrote it in Java. Yes it is Windows executable and works fine. It also opens with "os.execute()". But I can#t gete a return.

Quote
Can you show the code you are using? The only reason I can think all would be nil is if you are trying to access them outside the scope of the local, like if you are doing each line with ! commands.

Yes I did it with '!'.

Code: [Select]
!local status, exit_type, ret = os.exeute('wait_for_shoot_signal.exe')
!print(status)
!print(exit_type)
!print(ret)
!if status and exit_type == 'nil' and ret == 0 then print("sucess") end

Quote
FWIW, the suggestion I added in edit ( remote_on_wait ) might be a better solution for you, I didn't remember that feature until after I wrote the first part.

This would be with trigger over the USB Cable, right? I would prefer it, if the other solution would work because I have two separated systems. On for shoot and download (USB) and the oter for the trigger (over PC Input).


Re: Change timeout time for usb_sync_wait
« Reply #18 on: 05 / April / 2019, 02:24:01 »

What is the script you "made an .exe out of" ?
Normally an .exe would be a windows executable, but you could use a batch file or any other program you can run from the command line with os.execute. If you are not using windows, then a shell script or native executable would be fine too.


I wrote it in Java. Yes it is Windows executable and works fine. It also opens with "os.execute()". But I can`t get some returns.

Quote
Can you show the code you are using? The only reason I can think all would be nil is if you are trying to access them outside the scope of the local, like if you are doing each line with ! commands.

Yes I did it with '!'.

Code: [Select]
!local status, exit_type, ret = os.execute('wait_for_shoot_signal.exe')
!print(status)
!print(exit_type)
!print(ret)
!if status and exit_type == 'nil' and ret == 0 then print("sucess") end

Quote
FWIW, the suggestion I added in edit ( remote_on_wait ) might be a better solution for you, I didn't remember that feature until after I wrote the first part.

This would be with trigger over the USB Cable, right? I would prefer it, if the other solution would work because I have two separated systems. On for shoot and download (USB) and the oter for the trigger (over PC Input).
« Last Edit: 05 / April / 2019, 02:31:16 by R.Blickle »

Re: Change timeout time for usb_sync_wait
« Reply #19 on: 05 / April / 2019, 02:33:24 »
Quote
Can you show the code you are using? The only reason I can think all would be nil is if you are trying to access them outside the scope of the local, like if you are doing each line with ! commands.

Ok I have got it. Now this step works.

Code: [Select]
!local status, exit_type, ret = os.execute('wait_for_shoot_signal.exe') print(status) print(exit_type)print(ret)

 

Related Topics