1

I have two GoPro cameras that I can control through 10.5.5.9/x/x/x/ over WiFi - the thought process is that I can control both using two different network interfaces to connect to both cameras and then send a request to the URL (from earlier) and control both the cameras.

To test my theory I did the following commands in terminal:

curl --interface wlan0 http://10.5.5.9/gp/gpControl/command/shutter?p=1

curl --interface wlan1 http://10.5.5.9/gp/gpControl/command/shutter?p=1

Subsequently, this activates both cameras and they both begin recording. Great!

Putting this code into Python I tried the simple version of:

import os

resp = os.popen('curl --interface wlan0 http://10.5.5.9/gp/gpControl/command/shutter?p=1').read()
print(resp)
resp = os.popen('curl --interface wlan1 http://10.5.5.9/gp/gpControl/command/shutter?p=1').read()
print(resp)

But it only activates one camera and not the other, what is the reason behind this? I did the similar method using the answer to this question and it does the same, only activating one camera.

22
  • - Using python, the same camera is activated only once? Or twice? The reason to ask is to try to understand whether the --interface is being considered when passing the command to O.S. Commented Apr 6, 2020 at 20:11
  • 2
    - Consider using subprocess over os.popen (which is deprecated) docs.python.org/3.8/library/… Commented Apr 6, 2020 at 20:14
  • @silver It will send the command to one camera then try to send the same command to the same camera - which tells me it is not likely sending from a different interface. Same thing happens with the solution that I linked to. Commented Apr 6, 2020 at 20:24
  • Can you try to configure one of the wlans and the second camera in a different IP subnet? This would remove a handful of layers to look at. Which python version are you using? Commented Apr 6, 2020 at 20:40
  • @silver It looks like Python 3.6.9 Commented Apr 6, 2020 at 20:42

1 Answer 1

0

Try subprocess.run instead of os.popen:

import subprocess

resp = subprocess.run(["curl", "--interface", "wlan0", "http://10.5.5.9/gp/gpControl/command/shutter?p=1"], capture_output=True, shell=True)
print(resp)
resp = subprocess.run(["curl", "--interface", "wlan1", "http://10.5.5.9/gp/gpControl/command/shutter?p=1"], capture_output=True, shell=True)
print(resp)
Sign up to request clarification or add additional context in comments.

1 Comment

Check the comments -- this was one of the first changes suggested after the question was posted, and was reported to have no effect. (Also, the OP is on a version of Python old enough to not have run(), so it's necessary to operate on a Popen object explicitly).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.