Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working on asuswrt/merlinwrt #8

Open
siborg opened this issue Dec 7, 2016 · 9 comments
Open

Not working on asuswrt/merlinwrt #8

siborg opened this issue Dec 7, 2016 · 9 comments

Comments

@siborg
Copy link

siborg commented Dec 7, 2016

Thanks for the module it's excellent and it does what is says on the tin! It works fine on my desktop but fails to work in python3 environment on my home router (running asuswrt/mertinwrt) with entware. The module installs fine with easy-install but when trying to run the simple on/off switch operation it fails the mac discovery with the following errors:

Traceback (most recent call last):
  File "/opt/bin/spoff", line 3, in <module>
    displays = S20("192.168.1.89")
  File "/opt/lib/python3.5/site-packages/orvibo-1.1.1-py3.5.egg/orvibo/s20.py", line 137, in __init__
  File "/opt/lib/python3.5/site-packages/orvibo-1.1.1-py3.5.egg/orvibo/s20.py", line 187, in _discover_mac
orvibo.s20.S20Exception: Couldn't discover 192.168.1.89

The actual script I am running is trivial:

#!/opt/bin/python3 from orvibo.s20 import S20, discover displays = S20("192.168.1.89") if displays.on == False: print("Switching monitors extension on") displays.on = True else: print("Switching monitors studio extension off") displays.on = False

It probably has to do with the platform:

Kernel is 2.6.36.4 and is is running on arm-hf

@HankB
Copy link

HankB commented Dec 7, 2016 via email

@happyleavesaoc
Copy link
Owner

Make sure your firewall allows you to receive UDP broadcasts on port 10000. That's the most likely reason for failure.

@siborg
Copy link
Author

siborg commented Dec 7, 2016

I will double check. I am actually having problems running it on the firewall/router. However, with directly attached interfaces on the LAN, it should not matter. If it tries broadcast on all interfaces(including WAN) then the firewall possibly might be the issue.

@siborg
Copy link
Author

siborg commented Dec 7, 2016

I can confirm it is the firewall. Although I cannot disable it as it is my home router. I have modified lines 75 and 292 in s20.py within the egg package to use my LAN broadcast address rather than 255.255.255.255. After this modification, the code runs without an issue.

@happyleavesaoc
Copy link
Owner

Good to know. A more robust change would be to have discover take a broadcast address (defaulting to 255.255.255.255). That way it would be flexible for either use case. I'd welcome a PR that did that (along with a note in the readme).

@siborg
Copy link
Author

siborg commented Dec 7, 2016

I am not really a programmer. Just got a bit of intuition that's all but I'll see what can be done. No promises though.

@HankB
Copy link

HankB commented Dec 15, 2016

Finding broadcast addresses in Python (and w/out hacks such as having to edit /etc/hosts) is not so trivial. It turns out that someone has written a module that can do that. The module is 'netifaces' and I am wondering how the 'boss' here would feel about adding that dependency to this project?

I also found another cool thing (totally unrelated to this issue) about the Orvibo. If you google the name it uses to identify itself you can find a data sheet for the WiFi chip (High Flying) and that names a bunch of AT commands. There is one you can use to alter the default ID. My Asus router adds these IDs to it's DNS lookup tables and I can then access these devices by name instead of IP address. (I don't have the link handy - main development machine is down at the moment.)

@happyleavesaoc
Copy link
Owner

If I got a PR that used netifaces to discover the appropriate broadcast address, I'd certainly merge it.

@siborg
Copy link
Author

siborg commented Dec 15, 2016

I think it could be implemented in a much simpler way. You can either use private IP address classes (as per RFC1918) and their appropriate netmask (so for Class A 255.0.0.0.0, Class B 255.255.0.0 and for Class C 255.255.255.0) or, keep 255.255.255.255 but add an optional netmask parameter to the s20 class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants