5 void printSettings(
const tPvCameraInfo& info,
const tPvIpSettings& conf)
7 printf(
"\t%s - %7s - Unique ID = %lu\n", info.SerialString, info.DisplayName, info.UniqueId);
9 if (conf.ConfigMode & ePvIpConfigPersistent)
11 else if (conf.ConfigMode & ePvIpConfigDhcp)
12 printf(
"DHCP&AutoIP\n");
13 else if (conf.ConfigMode & ePvIpConfigAutoIp)
19 addr.s_addr = conf.CurrentIpAddress;
20 printf(
"\tAddress:\t%s\n", inet_ntoa(addr));
21 addr.s_addr = conf.CurrentIpSubnet;
22 printf(
"\tSubnet:\t\t%s\n", inet_ntoa(addr));
23 addr.s_addr = conf.CurrentIpGateway;
24 printf(
"\tGateway:\t%s\n", inet_ntoa(addr));
27 int main(
int argc,
char** argv)
30 printf(
"Usage: %s 10.68.0.20 [255.255.255.0] [0.0.0.0]\n", argv[0]);
34 char nm[] =
"255.255.255.0";
40 char gw[] =
"0.0.0.0";
51 char* ip_address = argv[1];
52 unsigned long IP = inet_addr(ip_address);
55 tPvErr err = PvCameraInfoByAddr(IP, &info, &conf);
57 printf(
"Camera found at requested IP address:\n");
61 printf(
"No camera found at %s, trying to change settings of a local camera...\n", ip_address);
64 printf(
"ERROR: No camera detected. Is it plugged in?\n");
68 printf(
"ERROR: Multiple cameras (%u) found. Do you have more than one plugged in?\n", (
unsigned)num_cams);
72 printf(
"Detected camera.\n");
75 if (PvCameraInfo(uid, &info)) {
76 printf(
"ERROR: could not retrieve camera info.\n");
79 if (PvCameraIpSettingsGet(uid, &conf)) {
80 printf(
"ERROR: could not retrieve camera IP settings.\n");
83 printf(
"Original settings:\n");
86 printf(
"Applying new settings...\n");
87 conf.ConfigMode = ePvIpConfigPersistent;
89 conf.CurrentIpAddress = conf.PersistentIpAddr = IP;
90 conf.CurrentIpSubnet = conf.PersistentIpSubnet = inet_addr(netmask);
91 conf.CurrentIpGateway = conf.PersistentIpGateway = inet_addr(gateway);
92 if (PvCameraIpSettingsChange(uid, &conf)) {
93 printf(
"ERROR: Failed to apply the new settings\n");
96 printf(
"New settings:\n");