Exemple #1
0
/*
 * Method:    OnRunning()
 * Purpose:   called when the thread is running (body)
 * Comments:  none
 */ 
tUint32 CSeeker::OnRunning()
{
    tPvCameraInfo Info;
    tPvErr lErr;
                                                                     
    if((lErr = PvCameraInfoByAddr(iAddr,&Info,NULL)))
        iFound = false;
    else
        iFound = true;     
   
    return lErr;
}
Exemple #2
0
int main(int argc, char* argv[])
{
    tPvErr errCode;
	
	// initialize PvAPI
	if((errCode = PvInitializeNoDiscovery())!= ePvErrSuccess)
    { 
		printf("PvInitialize err: %u\n", errCode);
	}
	else
    { 
        // the only command line argument accepted is the IP@ of the camera to be open
        if(argc>1)
        {
            //windows call to convert user input to IP address
			unsigned long IP = inet_addr(argv[1]);
             
            if((IP == INADDR_NONE) || (IP == INADDR_ANY))
			{
				printf("A valid IP address must be entered\n");
			}
			else
            {           
                tPvCameraInfo Info;
                tPvIpSettings Conf;

                if((errCode = PvCameraInfoByAddr(IP,&Info,&Conf)) == ePvErrSuccess)
                {
                    struct in_addr addr;
                
                    printf("-> %s - %s\n",Info.SerialString,Info.DisplayName);
                    printf("Mode supported:\t\t");
                    if(Conf.ConfigModeSupport & ePvIpConfigPersistent)
                        printf("FIXED,");
                    if(Conf.ConfigModeSupport & ePvIpConfigDhcp)
                        printf("DHCP,");
                    if(Conf.ConfigModeSupport & ePvIpConfigAutoIp)
                        printf("AutoIP");
                    printf("\n");
                    printf("Current mode:\t\t");
                    if(Conf.ConfigMode & ePvIpConfigPersistent)
                        printf("FIXED\n");
                    else
                    if(Conf.ConfigMode & ePvIpConfigDhcp)
                        printf("DHCP&AutoIP\n");
                    else
                    if(Conf.ConfigMode & ePvIpConfigAutoIp)
                        printf("AutoIP\n");
                    else
                        printf("None\n");    
    
                    addr.s_addr = Conf.CurrentIpAddress;
                    printf("Current address:\t%s\n",inet_ntoa(addr));
                    addr.s_addr = Conf.CurrentIpSubnet;
                    printf("Current subnet:\t\t%s\n",inet_ntoa(addr));
                    addr.s_addr = Conf.CurrentIpGateway;
                    printf("Current gateway:\t%s\n",inet_ntoa(addr));
                }
                else
                if(errCode == ePvErrTimeout)
                    printf("No camera was detected at the address you supplied\n");
                else
					printf("PvCameraInfoByAddr err: %u\n",errCode);         
			}      
        }
        else
            printf("usage : Ping <IP@>\n");

        // uninitialize the API
        PvUnInitialize();
	}

	return 0;
}
Exemple #3
0
int main(int argc, char** argv)
{
  if (argc < 2) {
    printf("Usage: %s 10.68.0.20 [255.255.255.0] [0.0.0.0]\n", argv[0]);
    return 0;
  }

  char nm[] = "255.255.255.0";
  char* netmask = nm;
  if (argc >= 3) {
    netmask = argv[2];
  }

  char gw[] = "0.0.0.0";
  char* gateway = gw;
  if (argc >= 4) {
    gateway = argv[3];
  }

  prosilica::init();
  // Make sure we call prosilica::fini() on exit.
  boost::shared_ptr<void> guard(static_cast<void*>(0), boost::bind(prosilica::fini));

  // Check if camera IP is already set
  char* ip_address = argv[1];
  unsigned long IP = inet_addr(ip_address);
  tPvCameraInfo info;
  tPvIpSettings conf;
  tPvErr err = PvCameraInfoByAddr(IP, &info, &conf);
  if (!err) {
    printf("Camera found at requested IP address:\n");
    printSettings(info, conf);
  }
  else {
    printf("No camera found at %s, trying to change settings of a local camera...\n", ip_address);
    size_t num_cams = prosilica::numCameras();
    if (num_cams == 0) {
      printf("ERROR: No camera detected. Is it plugged in?\n");
      return 1;
    }
    if (num_cams == 2) {
      printf("ERROR: Multiple cameras (%u) found. Do you have more than one plugged in?\n", (unsigned)num_cams);
      return 1;
    }
    
    printf("Detected camera.\n");
    unsigned long uid = prosilica::getGuid(0);
    
    if (PvCameraInfo(uid, &info)) {
      printf("ERROR: could not retrieve camera info.\n");
      return 1;
    }
    if (PvCameraIpSettingsGet(uid, &conf)) {
      printf("ERROR: could not retrieve camera IP settings.\n");
      return 1;
    }
    printf("Original settings:\n");
    printSettings(info, conf);

    printf("Applying new settings...\n");
    conf.ConfigMode = ePvIpConfigPersistent;
    //conf.ConfigMode = ePvIpConfigDhcp;
    conf.CurrentIpAddress = conf.PersistentIpAddr = IP;
    conf.CurrentIpSubnet = conf.PersistentIpSubnet = inet_addr(netmask);
    conf.CurrentIpGateway = conf.PersistentIpGateway = inet_addr(gateway);
    if (PvCameraIpSettingsChange(uid, &conf)) {
      printf("ERROR: Failed to apply the new settings\n");
      return 1;
    }
    printf("New settings:\n");
    printSettings(info, conf);
  }

  return 0;
}