Setting IPs via code
- Note
- This can also be done via GenICamBrowser.
Enable subnet discover
To set the IP configuration correctly, the start is at the interface level. The interface needs to be discovered. Afterwards, we configure the interface to allow subnets to be discovered, too. As interfaces complying with GenICam can be accessed the same way as cameras, we can set the desired properties, accordingly.
Cvb::DiscoverFlags::IgnoreGevFD |
Cvb::DiscoverFlags::IgnoreVins |
Cvb::DiscoverFlags::UpToLevelInterface,
std::chrono::milliseconds(2000));
auto interfaceInfo = interfaceInfoList[0];
interfaceInfo.SetGenApiFeature(CVB_LIT("TLInterface"), CVB_LIT("Cust::DisableSubnetMatch"), CVB_LIT("1"));
interfaceInfo.SetGenApiFeature(CVB_LIT("TLInterface"), CVB_LIT("Cust::AllowBroadcastDiscoveryResponse"), CVB_LIT("1"));
static std::vector< DiscoveryInformation > Discover()
var interfaceInfoList = DeviceFactory.Discover(DiscoverFlags.IgnoreVins);
var interfaceInfo = interfaceInfoList[0];
interfaceInfo.SetGenApiFeature("TLDevice","Cust::DisableSubnetMatch","1");
interfaceInfo.SetGenApiFeature("TLDevice","Cust::AllowBroadcastDiscoveryResponse","1");
interface_info.set_genapi_feature("TLInterface", "Cust::DisableSubnetMatch", "1")
interface_info.set_genapi_feature("TLInterface", "Cust::AllowBroadcastDiscoveryResponse", "1")
List[cvb.DiscoveryInformation] discover_from_root(int flags=cvb.DiscoverFlags.FindAll, int time_span=300)
Open Device And Query Nodes
After accessing different subnets we are able to also discover devices outside our specific address space. A new discover will detect all devices connected to the NIC in all subnets using the same access token again. After opening the interface, the TLInterface
nodemap can be queried for all nodes related to the IP setting process.
auto interfaceNM = interfaceDevice->NodeMap(CVB_LIT("TLInterface"));
auto deviceUpdateListNode = interfaceNM->Node<
Cvb::CommandNode>(CVB_LIT(
"DeviceUpdateList"));
auto ipNode = interfaceNM->Node<
Cvb::IntegerNode>(CVB_LIT(
"GevDeviceForceIPAddress"));
auto subnetNode = interfaceNM->Node<
Cvb::IntegerNode>(CVB_LIT(
"GevDeviceForceIPSubnetMask"));
auto subnetNode = interfaceNM->Node<
Cvb::IntegerNode>(CVB_LIT(
"GevDeviceForceIPGateway"));
auto forceIPNode = interfaceNM->Node<
Cvb::CommandNode>(CVB_LIT(
"GevDeviceForceIP"));
auto configurationStatusNode = interfaceNM->Node<
Cvb::EnumerationNode>(CVB_LIT(
"GevDeviceIPConfigurationStatus"));
static std::shared_ptr< T > Open(const String &provider, AcquisitionStack acquisitionStack=AcquisitionStack::PreferVin)
var interfaceDevice = DeviceFactory.Open(devices[0].AccessToken);
var interfaceNM = interfaceDevice.NodeMaps["TLInterface"];
var deviceUpdateList = interfaceNM["DeviceUpdateList"] as CommandNode;
var gDIPConfigStatus = interfaceNM["GevDeviceIPConfigurationStatus"] as EnumerationNode;
var gDFIPAddress = interfaceNM["GevDeviceForceIPAddress"] as IntegerNode;
var gDFIPSubnetMask = interfaceNM["GevDeviceForceIPSubnetMask"] as IntegerNode;
var gDFIPGateway = interfaceNM["GevDeviceForceIPGateway"] as IntegerNode;
var gDFIPCmd = interfaceNM["GevDeviceForceIP"] as CommandNode;
device_discover =
cvb.DeviceFactory.discover_from_level(info.access_token, cvb.DiscoverFlags.IgnoreVins|cvb.DiscoverFlags.IgnoreGevFD|cvb.DiscoverFlags.UpToLevelDevice|cvb.DiscoverFlags.IncludeInaccessible)
dev_node_map = device.node_maps["TLInterface"]
device_update_list = dev_node_map["DeviceUpdateList"]
gev_dev_IP_config_status = dev_node_map["GevDeviceIPConfigurationStatus"]
gev_dev_force_IP_address = dev_node_map["GevDeviceForceIPAddress"]
gev_dev_force_IP_subnet_mask = dev_node_map["GevDeviceForceIPSubnetMask"]
gev_dev_force_IP_gateway = dev_node_map["GevDeviceForceIPGateway"]
gev_dev_force_IP = dev_node_map["GevDeviceForceIP"]
Union[cvb.GenICamDevice, cvb.VinDevice, cvb.EmuDevice, cvb.VideoDevice, cvb.NonStreamingDevice] open(str provider, int acquisition_stack=cvb.AcquisitionStack.PreferVin)
List[cvb.DiscoveryInformation] discover_from_level(str access_token, int flags=cvb.DiscoverFlags.FindAll, int time_span=300)
Node name | Description |
DeviceUpdateList | Command Node that makes the nodemap aware of updates |
GevDeviceIPConfigurationStatus | Sets the IP mode: PersistentIP or TemporaryIP |
GevDeviceForceIPAddress | Integer Node to set the desired IP address |
GevDeviceForceIPSubnetMask | Integer Node to set the desired subnet mask |
GevDeviceForceIPGateway | Integer node to set the desired default gateway |
GevDeviceForceIP | Command Node to apply the changes |
Set the IP temporarily (optional)
Now it is time to set the IP addresses. For setting persistent IP addresses to devices that are not in the same subnet, a temporary IP address has to be set before. This step is not mandatory for devices, that already reside in the same subnet. For simplicity only the IP and the subnet is set.
deviceUpdateListNode->Execute();
configurationStatusNode->SetValue("TemporaryIP");
ipNode->SetValue(0x0A000003);
forceIPNode->Execute();
void SetValue(std::int64_t value)
deviceUpdateList.Execute();
gDIPConfigStatus.Value = "TemporaryIP";
gDFIPAddress.Value = 0x0A000002;
gDFIPSubnetMask.Value = 0xFFFFFF00;
gDFIPCmd.Execute();
device_update_list.Execute()
gev_dev_IP_config_status.value = "TemporaryIP"
gev_dev_force_IP_address.value = 0x0A000002
gev_dev_force_IP_subnet_mask.value = 0xFFFFFF00
gev_dev_force_IP.Execute()
Set the IP persistently
It is now required to wait for the device to apply these changes, before going on. Afterwards, the IP is set persistently in the same manner.
deviceUpdateListNode->Execute();
configurationStatusNode->SetValue("PersistentIP");
ipNode->SetValue(0x0A000003);
forceIPNode->Execute();
deviceUpdateList.Execute();
gDIPConfigStatus.Value = "PersistentIP";
gDFIPAddress.Value = 0x0A000002;
gDFIPSubnetMask.Value = 0xFFFFFF00;
gDFIPCmd.Execute();
device_update_list.Execute()
gev_dev_IP_config_status.value = "PersistentIP"
gev_dev_force_IP_address.value = 0x0A000002
gev_dev_force_IP_subnet_mask.value = 0xFFFFFF00
gev_dev_force_IP.Execute()