Bloodevil / sony_camera_api

sony camera remote api
http://developer.sony.com/develop/cameras/
MIT License
244 stars 60 forks source link

Possible to choose which interface to search on? #31

Open MarekRzewuski opened 7 years ago

MarekRzewuski commented 7 years ago

Hello, I'm running VirtualBox sharing USB WIFI-dongle as Bridged Adapter from Windows. My virtualbox seems to have two network cards.

Also when running on Raspberry PI I have 3 network cards (1 wired and 2 WIFI).

By default dump_camera_capabilities.py does not find any camera. I need to modify __bind_sockets() and add .bind() to choose which interface should be searched. Like this:

    self.__udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    self.__udp_socket.bind(('192.168.122.178',0))
    self.__udp_socket.settimeout(0.1)

192.168.122.178 is IP which I get from camera.

Is there a way to search all interfaces and select which camera should be used? I guess there may be several cameras found on different interfaces.

Bloodevil commented 7 years ago

I never tried on VM but I think you can connect manually. and searching is not working properly (There are many issues on camera side. even if you didn't use VM

mungewell commented 6 years ago

You could try the attached patch, attempts do a discovery on each interface in turn.

For me (Xubuntu) this doesn't work as it return all the interfaces with the same IP. This 'glitch' is noted here: https://groups.google.com/forum/#!topic/comp.lang.python/tF-SXWvBVjk

Netdisco (https://github.com/home-assistant/netdisco) finds all camera attached on multiple interfaces, using 'netifaces'. But not sure we want to put added requirements on the code. patch.txt

nurupo commented 4 years ago

Had the same issue. pysony wasn't able to find the camera until I told it to broadcast on the right network interface with the bind():

diff --git a/src/pysony.py b/src/pysony.py
index 6e7d845..931e812 100755
--- a/src/pysony.py
+++ b/src/pysony.py
@@ -44,6 +44,7 @@ class ControlPoint(object):
         sock.settimeout(0.1)
         # Set the socket to broadcast mode.
         sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)
+        sock.bind(('10.0.1.1', 0))
         self._udp_socket = sock

     def close(self):

10.0.1.1 is the address assigned to my machine by camera's access point.