43 int main(
int argc,
char *argv[])
49 if (argc > 1 && std::string(argv[1]) !=
"-h")
53 if (std::string(argv[1]) ==
"-l")
55 std::cout <<
"Available GigE Vision devices:" << std::endl;
59 for (
size_t i=0; i<system.size(); i++)
63 std::vector<std::shared_ptr<rcg::Interface> > interf=system[i]->getInterfaces();
65 for (
size_t k=0; k<interf.size(); k++)
69 std::vector<std::shared_ptr<rcg::Device> > device=interf[k]->getDevices();
71 for (
size_t j=0; j<device.size(); j++)
73 if (device[j]->getTLType() ==
"GEV")
75 std::cout <<
" " << interf[k]->getID() <<
":" << device[j]->getSerialNumber() <<
" (";
77 std::string uname=device[j]->getDisplayName();
81 std::cout << uname <<
", ";
84 std::cout << device[j]->getID() <<
")" << std::endl;
103 bool showsummary=
false;
109 if (i == argc || (i+1 == argc && std::string(argv[i]) ==
"--iponly"))
121 std::shared_ptr<GenApi::CNodeMapRef> nodemap=dev->getRemoteNodeMap();
125 std::string p=argv[i++];
131 else if (p[0] ==
'-' && i < argc)
141 rcg::setString(nodemap,
"GevCurrentIPConfigurationDHCP", argv[i++],
true);
145 rcg::setString(nodemap,
"GevCurrentIPConfigurationPersistentIP", argv[i++],
true);
165 std::cerr <<
"Unknown parameter: " << p << std::endl;
169 else if (p.find(
'=') != std::string::npos)
173 size_t k=p.find(
'=');
174 std::string value=p.substr(k+1);
175 std::string key=p.substr(0, k);
192 std::cout <<
rcg::getString(nodemap,
"GevCurrentIPAddress") << std::endl;
194 else if (showsummary)
196 std::cout <<
"ID: " << dev->getParent()->getID() <<
":" 198 std::cout <<
"GenTL ID: " << dev->getID() << std::endl;
199 std::cout <<
"Serial number: " <<
rcg::getString(nodemap,
"DeviceID") << std::endl;
200 std::cout <<
"User defined ID: " <<
rcg::getString(nodemap,
"DeviceUserID") << std::endl;
201 std::cout <<
"MAC Address: " <<
rcg::getString(nodemap,
"GevMACAddress") << std::endl;
202 std::cout << std::endl;
204 std::cout <<
"Current IP: " <<
rcg::getString(nodemap,
"GevCurrentIPAddress") << std::endl;
205 std::cout <<
"Current subnet mask: " <<
rcg::getString(nodemap,
"GevCurrentSubnetMask") << std::endl;
206 std::cout <<
"Current gateway: " <<
rcg::getString(nodemap,
"GevCurrentDefaultGateway") << std::endl;
207 std::cout << std::endl;
209 std::cout <<
"Persistent IP on/off: " <<
rcg::getString(nodemap,
"GevCurrentIPConfigurationPersistentIP") << std::endl;
210 std::cout <<
" Persistent IP: " <<
rcg::getString(nodemap,
"GevPersistentIPAddress") << std::endl;
211 std::cout <<
" Persistent subnet mask: " <<
rcg::getString(nodemap,
"GevPersistentSubnetMask") << std::endl;
212 std::cout <<
" Persistent gateway: " <<
rcg::getString(nodemap,
"GevPersistentDefaultGateway") << std::endl;
213 std::cout <<
"DHCP on/off: " <<
rcg::getString(nodemap,
"GevCurrentIPConfigurationDHCP") << std::endl;
214 std::cout <<
"Link local on/off: " <<
rcg::getString(nodemap,
"GevCurrentIPConfigurationLLA") << std::endl;
215 std::cout << std::endl;
217 std::cout <<
"PTP: " <<
rcg::getString(nodemap,
"GevIEEE1588") << std::endl;
218 std::cout <<
"PTP status: " <<
rcg::getString(nodemap,
"GevIEEE1588Status") << std::endl;
225 std::cerr <<
"Cannot find device: " << argv[1] << std::endl;
232 std::cout << argv[0] <<
" -h | -l | ([<interface-id>:]<device-id> <options> ...)" << std::endl;
233 std::cout << std::endl;
234 std::cout <<
"Configuration of a GigE Vision device via GenICam." << std::endl;
235 std::cout << std::endl;
236 std::cout <<
"-h Prints help information and exits" << std::endl;
237 std::cout <<
"-l Lists all available GigE Vision devices" << std::endl;
238 std::cout << std::endl;
239 std::cout <<
"Parameters:" << std::endl;
240 std::cout <<
"<interface-id> Optional GenICam ID of interface for connecting to the device" << std::endl;
241 std::cout <<
"<device-id> GenICam device ID, serial number or user defined name of device" << std::endl;
242 std::cout << std::endl;
243 std::cout <<
"Options:" << std::endl;
244 std::cout <<
"-n <id> Set user defined id" << std::endl;
245 std::cout <<
"-d 1|0 Switch DHCP on or off" << std::endl;
246 std::cout <<
"-p 1|0 Switch persistent IP on or off" << std::endl;
247 std::cout <<
"-t 1|0 Switch precision time protocol (ptp) on or off" << std::endl;
248 std::cout <<
"-i <ip> Set persistent IP address" << std::endl;
249 std::cout <<
"-s <ip> Set subnet mask for persistent IP address" << std::endl;
250 std::cout <<
"-g <ip> Set default gateway for persistent IP address" << std::endl;
251 std::cout <<
"--iponly Show current IP of device instead of full summary" << std::endl;
252 std::cout <<
"<key>=<value> Optional GenICam parameters to be changed in the given order" << std::endl;
256 catch (
const std::exception &ex)
258 std::cerr << ex.what() << std::endl;
bool setIPV4Address(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, const char *value, bool exception)
Set the value of an integer feature of the given nodemap from an IP address.
std::shared_ptr< Device > getDevice(const char *id)
Searches across all transport layers and interfaces for a device.
static std::vector< std::shared_ptr< System > > getSystems()
Returns a list of systems (i.e.
int main(int argc, char *argv[])
static void clearSystems()
Clears the internal list of systems.
bool setString(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, const char *value, bool exception)
Set the value of a feature of the given nodemap.
bool callCommand(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, bool exception)
Calls the given command.
std::string getString(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, bool exception, bool igncache)
Get the value of a feature of the given nodemap.