30 Change the IP address of a Hokuyo URG Laser
38 Each address must have 4
40 if len(argument.split(
".")) != 4:
41 print(
"Invalid %s, must be of the form xxx.yyy.zzz.www" % name)
44 for x
in argument.split(
"."):
46 print(
"Invalid %s, must be of the form xxx.yyy.zzz.www" % name)
53 if __name__ ==
"__main__":
54 parser = argparse.ArgumentParser(description=__doc__)
55 parser.add_argument(
'new_ip', help=
'The desired IP address for the laser')
56 parser.add_argument(
'new_gw', help=
'The desired gateway for the laser')
57 parser.add_argument(
'--nm', help=
'The desired netmask for the laser', default=
"255.255.255.0")
58 parser.add_argument(
'--ip', help=
'The current IP address of the laser', default=
"192.168.0.10")
59 args = parser.parse_args()
68 msg =
"$IP" + ip + nm + gw +
"\x0a"
70 print(
"Connecting to %s" % args.ip)
71 sock = socket.socket()
72 sock.connect((args.ip, 10940))
74 print(
"Updating settings")
77 sock.send(msg.encode(
'utf-8'))
82 returned = sock.recv(40)
83 except socket.timeout:
84 print(
"Laser did not return any packet, is probably not updated.")
89 if msg.encode(
'utf-8') != returned:
90 print(
"Laser does not appear to have updated")
93 print(
"Done updating, cycle power on laser")