How do I find the Yun IP address in a Python script
i'm working on wifi controlled robot using yun. have working proto-type using mega 2560 wifi shield, want port yun because compact mega wifi shield.
i have pc application sends data on wifi robot. robot needs read data , change servos or i/o pins based on values.
i've seen several python scripts open socket read data. in examples found, ip address hard coded in script. don't want have edit python script every time ip address changes. there pretty-wifi-status.lua script works example sketch, in lua, not python.
this script works on pc, errors on yun.
the error is:
file "getip.py", line 3, in <module>
address = socket.gethostbyname("%s.local" % hostname)
socket.gaierror: [errno -2] name or service not known
can tell me doing wrong or way wifi ip address of yun within python?
i have pc application sends data on wifi robot. robot needs read data , change servos or i/o pins based on values.
i've seen several python scripts open socket read data. in examples found, ip address hard coded in script. don't want have edit python script every time ip address changes. there pretty-wifi-status.lua script works example sketch, in lua, not python.
this script works on pc, errors on yun.
code: [select]
import socket
hostname = socket.gethostname()
address = socket.gethostbyname("%s.local" % hostname)
addr = address
print addr
the error is:
file "getip.py", line 3, in <module>
address = socket.gethostbyname("%s.local" % hostname)
socket.gaierror: [errno -2] name or service not known
can tell me doing wrong or way wifi ip address of yun within python?
Arduino Forum > Products > Arduino Yún (Moderator: fabioc84) > How do I find the Yun IP address in a Python script
arduino
Comments
Post a Comment