41 import libmultisense
as lms
45 channel_config = lms.ChannelConfig()
46 channel_config.ip_address = args.current_ip_address
47 channel_config.connect_on_initialization = (args.interface
is None)
49 with lms.Channel.create(channel_config)
as channel:
51 print(
"Invalid channel")
54 if not args.disable_confirmation:
55 print(f
"NEW address {args.new_ip_address}")
56 print(f
"NEW gateway {args.new_gateway}")
57 print(f
"NEW netmask {args.new_netmask}")
59 if args.interface
is not None:
60 print(f
"** WARNING: All MultiSense devices attached to the interface {args.interface} "
61 "will have their IPs changed **")
63 res = input(
"Really update network configuration? (y/n):")[0]
64 if res !=
'Y' and res !=
'y':
68 config = lms.NetworkInfo()
69 config.ip_address = args.new_ip_address
70 config.gateway = args.new_gateway
71 config.netmask = args.new_netmask
72 status = channel.set_network_config(config, args.interface)
73 if status != lms.Status.OK:
78 if __name__ ==
'__main__':
79 parser = argparse.ArgumentParser(
"LibMultiSense change ip utility")
80 parser.add_argument(
"-a",
"--current-ip_address", default=
"10.66.171.21", help=
"The current IPv4 address of the MultiSense.")
81 parser.add_argument(
"-A",
"--new-ip_address", default=
"10.66.171.21", help=
"The new IPv4 address of the MultiSense.")
82 parser.add_argument(
"-G",
"--new-gateway", default=
"10.66.171.1", help=
"The new IPv4 gateway of the MultiSense.")
83 parser.add_argument(
"-N",
"--new-netmask", default=
"255.255.255.0", help=
"The new IPv4 netmask of the MultiSense.")
84 parser.add_argument(
"-b",
"--interface", help=
"send broadcast packet to a specified network interface. "
85 "This resets the IP address to the new configured ip")
86 parser.add_argument(
"-y",
"--disable-confirmation", action=
'store_true', help=
"Disable confirmation prompts")
87 main(parser.parse_args())