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.
-
Open the sample in HDevelop: Open HDevelop, and drag the sample into HDevelop.
-
Step over the program (click the button in the toolbar repeatedly), until the Variable Inspect: MechEyeCamers window pops up.
-
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:.
user_name is the custom camera name. You can customize the camera name in Mech-Eye Viewer. -
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 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:
-
Click in the toolbar to reset program execution.
-
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'
-
Run the sample by clicking in the toolbar or pressing the F5 key.
-
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:
-
Click in the toolbar to reset program execution.
-
Locate the following line, and replace true with false.
set_framegrabber_param (AcqHandle, 'GevCurrentIPConfigurationPersistentIP', true)
-
Run the sample by clicking in the toolbar or pressing the F5 key.
-
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. |