38 #ifndef WIN32_LEAN_AND_MEAN
39 #define WIN32_LEAN_AND_MEAN 1
56 #include <MultiSense/MultiSenseChannel.hh>
66 void usage(
const char *name)
68 std::cerr <<
"USAGE: " << name <<
" -e <extrinsics-file> -i <intrinsics-file> [<options>]" << std::endl;
69 std::cerr <<
"Where <options> are:" << std::endl;
70 std::cerr <<
"\t-a <current-address> : CURRENT IPV4 address (default=10.66.171.21)" << std::endl;
71 std::cerr <<
"\t-A <new-address> : NEW IPV4 address (default=10.66.171.21)" << std::endl;
72 std::cerr <<
"\t-G <new-gateway> : NEW IPV4 gateway (default=10.66.171.1)" << std::endl;
73 std::cerr <<
"\t-N <new-netmask> : NEW IPV4 netmask (default=255.255.255.0)" << std::endl;
74 std::cerr <<
"\t-b <interface> : send broadcast packet to a specified network interface."
75 "This resets the IP address to the new configured IP" << std::endl;
76 std::cerr <<
"\t-y : Disable confirmation prompt (default=false)" << std::endl;
82 int main(
int argc,
char** argv)
84 std::string ip_address =
"10.66.171.21";
85 std::string new_ip_address =
"10.66.171.21";
86 std::string new_gateway =
"10.66.171.1";
87 std::string new_netmask =
"255.255.255.0";
88 std::optional<std::string>
interface = std::nullopt;
89 bool disable_confirmation =
false;
92 while(-1 != (c =
getopt(argc, argv,
"a:A:G:N:b:y")))
96 case 'a': ip_address = std::string(
optarg);
break;
97 case 'A': new_ip_address = std::string(
optarg);
break;
98 case 'G': new_gateway = std::string(
optarg);
break;
99 case 'N': new_netmask = std::string(
optarg);
break;
100 case 'b':
interface = std::string(
optarg);
break;
101 case 'y': disable_confirmation =
true;
break;
102 default:
usage(*argv);
break;
106 lms::Channel::Config config{ip_address};
107 config.connect_on_initialization =
static_cast<bool>(interface);
112 std::cerr <<
"Failed to create channel" << std::endl;
116 if (!disable_confirmation)
118 std::cout <<
"NEW address: " << new_ip_address << std::endl;;
119 std::cout <<
"NEW gateway: " << new_gateway << std::endl;;
120 std::cout <<
"NEW netmask: " << new_netmask << std::endl;;
124 std::cout <<
"** WARNING: All MultiSense devices attached to interface " << interface.value() <<
125 "will have their addresses changed **" << std::endl;
128 std::cerr <<
"Really update network configuration? (y/n):" << std::endl;
130 int reply = getchar();
131 if (
'Y' != reply &&
'y' != reply)
133 std::cout <<
"Aborting" << std::endl;
138 const lms::MultiSenseInfo::NetworkInfo new_info{new_ip_address, new_gateway, new_netmask};
140 if (
const auto status = channel->set_network_config(new_info, interface); status != lms::Status::OK)
142 std::cerr <<
"Unable to set new IP address: " <<
lms::to_string(status) << std::endl;