Obtain and Modify IP Configuration

This topic introduces how to obtain and modify the current IP address, subnet mask, and gateway of the camera with the configure_camera_ip_address sample on Windows.

Please refer to Usage Guide for HALCON Samples to obtain the samples and check the prerequisites for using the samples.

Select the Camera

Follow these steps to select the camera whose IP configuration you want to obtain or modify.

  1. Open the sample in HDevelop: Open HDevelop, and drag the sample into HDevelop.

  2. Step over the program (click the step over button in the toolbar repeatedly), until the Variable Inspect: MechEyeCamers window pops up.

  3. This window displays all the available cameras. Double-click the camera that you want to connect, and copy the name after unique_name: or user_name:.

    camera name
    user_name is the custom camera name. You can customize the camera name in Mech-Eye Viewer.
  4. Locate the following line, and replace MechEye with the copied unique_name or user_name.

    DeviceInfo := 'MechEye'

Obtain Camera IP Address, Subnet Mask and Gateway

Follow these steps to obtain the current IP address, subnet mask and gateway of the camera:

Run the sample by clicking run in the toolbar or pressing the F5 key. In the Control Variables area, check the following variables for the current IP address, subnet mask, and gateway of the camera.

  • CurrentIPAddressString: IP address

  • CurrentSubnetMaskString: subnet mask

  • CurrentDefaultGatewayString: gateway

If the camera firmware version is 2.0.2 or below, the above information cannot be obtained, and the error message will be recorded in the Exception variable.

Set Static IP address

This sample sets a static IP address by default. Follow these steps to modify the IP address, subnet mask and gateway of the camera:

  1. Click reset in the toolbar to reset program execution.

  2. Locate the following line, and change the IP address, subnet mask and gateway to the values to be set:

    IPAddressString := '192.168.1.100'
    SubnetMaskString := '255.255.255.0'
    DefaultGatewayString := '192.168.1.1'
  3. Run the sample by clicking run in the toolbar or pressing the F5 key.

  4. Restart the camera to make the new settings take effect.

Set Dynamic IP Address

Follow these steps to dynamically assign an IP address to the camera:

  1. Click reset in the toolbar to reset program execution.

  2. Locate the following line, and replace true with false.

    set_framegrabber_param (AcqHandle, 'GevCurrentIPConfigurationPersistentIP', true)
  3. Run the sample by clicking run in the toolbar or pressing the F5 key.

  4. Restart the camera to make the new settings take effect.

When the camera is connected to the computer directly, the IP address of the camera cannot be dynamically assigned.