Using USB remote to control chdkptp with Raspberry Pi

  • 62 Replies
  • 1492 Views
Re: Using USB remote to control chdkptp with Raspberry Pi
« Reply #60 on: 19 / April / 2017, 23:12:54 »
Advertisements
What do I need to fix?
The second occurrence of get_tick_count is missing the brackets? 

i.e. return get_tick_count() - t0
Ported : A1200  SD940  G10  Powershot N  G16*

Re: Using USB remote to control chdkptp with Raspberry Pi
« Reply #61 on: 21 / April / 2017, 22:23:45 »
The second occurrence of get_tick_count is missing the brackets? 

i.e. return get_tick_count() - t0

Ah, yep. Simple solution. Haha, thank you.


Finding out when video started in chdkptp is easy enough, but with your current setup getting the information back to your python program may be tricky.

To wait for video to start recording, you could use something like
Code: [Select]
click('video') repeat sleep(10) until get_video_status() == 4

Is there a way for me to execute this code on the camera and then have it output something that I could return back to my Python program? What I mean is... do you believe it's possible for me to execute this program with chdk like this:
Code: [Select]
remote_function.py|chdkptp.sh|remote_function.py

I realize it is a lot more tricky to do this through Python than if I were using Lua, but I'm in way too deep with everything else involved in this project. If I can get an output back from chdkptp, that would be perfect... Like as soon as my get_movie_status == 4, I could output something to my program and from there start my audio recording.

Thanks again for all the help. Total life savers.

*

Offline reyalp

  • ******
  • 10343
Re: Using USB remote to control chdkptp with Raspberry Pi
« Reply #62 on: Yesterday at 00:16:08 »
Code: [Select]
remote_function.py|chdkptp.sh|remote_function.py
You can't do it like that, since the second instance of the python script would be totally separate from the first. What you would need to do is use python subprocess functions to open chdkptp, with both standard input and output connected. But as I mentioned earlier, this is tricky, and my knowledge of python is minimal, so I couldn't help you without going and reading the python manuals myself.
Quote
If I can get an output back from chdkptp, that would be perfect... Like as soon as my get_movie_status == 4, I could output something to my program and from there start my audio recording.
I did mention a couple of possible ways of dealing with this in my earlier post: https://chdk.setepontos.com/index.php?topic=13062.msg132426#msg132426

The file hack is probably what I would do if I just wanted to get it done without having to figure too much out. If you can make a loop in python that checks for the existence of a file, you can make it work.  (edit: There are undoubtedly more "correct" ways to do this, but sometimes doing the thing you know how to do is the quickest solution)

If your audio recording command just needs something standard input, using popen in from chdkptp lua instead of python should be pretty simple too.
« Last Edit: Yesterday at 00:18:27 by reyalp »
Don't forget what the H stands for.

 

Related Topics