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")
78 returned = sock.recv(40)
79 except socket.timeout:
80 print(
"Laser did not return any packet, is probably not updated.")
83 print(
"Laser does not appear to have updated")
85 print(
"Done updating, cycle power on laser")
def parse_and_validate_ipv4(argument, name)