Ethernet Cameras
Reaching a camera over the network, and changing the address it holds itself. Name the serial rather than an address: that form works whether the camera is on USB or on Ethernet.
In Fahrenheit: with the SDK switched to Fahrenheit (SetTemperatureUnit() and its counterparts, see Temperatures in Fahrenheit), every temperature on this page is read and written in Fahrenheit, and every difference in Fahrenheit degrees; the samples are unchanged.
The device-communication chapter is three pages:
| Page | Question |
|---|---|
| Device Communication | What does opening a camera involve, what does it do over USB, and how long does it wait? |
| Ethernet Cameras | How do I reach one over the network, and set its address? |
| Dropped Connections | It dropped out. What does the SDK do, and what do I have to do? |
On this page
- Opening a Network Camera - From an enumerated entry - Naming an address -
kNetworknever falls back to USB - The C forms - Network Configuration - Set the mask, not only the address - The stream destination looks after itself - There is no DHCP, and no gateway - Setting an address by broadcast - Reading it, and writing it back - What
SetNetworkConfig()returns - An address change keeps the connection -kUnchangedandkAppliedPendingEthernet- When the camera refuses - Firewall requirements on the host - Write the rule for the program, not for the port - An application's own installer is where its rule belongs - Give each camera its own port - Control
- Streaming
Devices with an Ethernet control plane: Xi 80, Xi 320 MT, Xi 410, Xi 410 MT, Xi 640 ETH, Xi 1M. All but the Xi 640 ETH stream to a configurable destination port, 50101 from the factory; the exception is spelled out immediately below.
The Xi 640 ETH is also opened over the network, and it is the exception to everything in this section that mentions a port: its ports are fixed at 9999 for frames and 9998 for status, they are not configurable, and two of them in one process therefore cannot be kept apart by moving one. Its firewall rule has to cover those two ports, or, better, be written for the program.
Opening a Network Camera
Name the camera and nothing else. A camera is its serial number, and the SDK works out where it is:
optris::sdk::ImagerConfig config; config.serial = "26074397"; auto imager = optris::sdk::Imager::Create(config);
camera = optris_sdk.Camera.open(serial='26074397')
This is Transport::kAuto, the default. The SDK looks on USB first, and only if the serial is not there does it broadcast for it on the network. A USB application therefore pays nothing for the network being supported, and an application whose camera moves onto a network cable does not have to be rewritten.
Empty and unknown are different requests, and only one of them opens a camera. An empty serial means "any camera" and takes the first one found. A serial that names a camera which is not attached fails, naming that serial, and never quietly opens a different one. The reason is that the mistake is undetectable afterwards: frames carry no mark saying which device produced them, so an application that asked for one camera and silently got another measures the wrong thing and reports success. It has to be refused at the open.
The serial is also validated before any camera is touched: decimal digits only, and not "0". No camera carries serial zero, so "0" is refused rather than read as "any camera"; otherwise a serial that arrived from a config file as a default, or from a failed string conversion, would open an arbitrary camera. Anything that is not a plain number raises ConfigException.
From an enumerated entry
Open an entry straight from enumeration; it already carries the address, so nothing is looked up twice:
optris::sdk::EnumerationOptions opts; opts.include_network = true; std::unique_ptr<optris::sdk::Imager> imager; for (const auto &device : optris::sdk::EnumerateDevices(opts)) { if (device.connection == optris::sdk::ConnectionType::kNetwork) { imager = optris::sdk::Imager::Create(device); break; } }
optris_sdk_enumeration_options opts; optris_sdk_device_list *devices = NULL; optris_sdk_device_info device; optris_sdk_imager *camera = NULL; size_t count = 0; size_t i; optris_sdk_enumeration_options_init(&opts, sizeof(opts)); opts.include_network = 1; optris_sdk_enumerate_devices(&opts, &devices); optris_sdk_device_list_get_count(devices, &count); for (i = 0; i < count; ++i) { optris_sdk_device_list_get(devices, i, &device); if (device.connection == OPTRIS_SDK_CONNECTION_NETWORK) { optris_sdk_imager_create_from_device(&device, &camera); break; } } optris_sdk_device_list_free(devices);
ThermalCamera? camera = null; foreach (DeviceInfo device in Sdk.EnumerateDevices( new Optris.Sdk.EnumerationOptions { IncludeNetwork = true })) { if (device.Connection == ConnectionType.Network) { camera = ThermalCamera.Open(device); break; } }
options = optris_sdk.EnumerationOptions(include_network=True) camera = None for device in optris_sdk.enumerate_devices(options): if device.connection == optris_sdk.CONNECTION_NETWORK: camera = optris_sdk.Camera.open(device) break
let devices = enumerate_with(&EnumerationOptions::new().include_network(true))?; let mut camera = None; for device in &devices { if device.connection == ConnectionType::Network { camera = Some(Camera::open_device(device)?); break; } }
A DeviceInfo from enumeration carries the address it answered from, so keep the whole entry. A caller that keeps only the serial has thrown the address away, and for a camera on another subnet cannot get it back.
Naming an address
When the camera is not on this host's own segment, discovery cannot reach it: a broadcast does not cross a router, so such a camera has to be addressed:
optris::sdk::ImagerConfig config; config.serial = "26074397"; // which camera to accept config.transport = optris::sdk::Transport::kNetwork; config.network.address = "10.0.0.21"; // where to look config.network.connect_timeout = std::chrono::seconds{5}; auto imager = optris::sdk::Imager::Create(config);
optris_sdk_network_target target; optris_sdk_imager *camera = NULL; optris_sdk_network_target_init(&target, sizeof(target)); strncpy(target.serial, "26074397", sizeof(target.serial) - 1); /* which camera to accept */ strncpy(target.address, "10.0.0.21", sizeof(target.address) - 1); /* where to look */ target.connect_timeout_ms = 5000; optris_sdk_imager_create_network(&target, &camera);
await using ThermalCamera camera = ThermalCamera.Open(new NetworkTarget { Serial = "26074397", // which camera to accept Address = "10.0.0.21", // where to look ConnectTimeout = TimeSpan.FromSeconds(5), });
camera = optris_sdk.Camera.open_network( serial='26074397', # which camera to accept address='10.0.0.21', # where to look connect_timeout_s=5.0)
let target = NetworkTarget::new() .serial("26074397")? // which camera to accept .address("10.0.0.21")? // where to look .connect_timeout_ms(5000); let camera = Camera::open_network(&target)?;
Name the serial as well when you know it. An address says where to look; the serial says which camera to accept, and on a plant an address gets reassigned. Naming both means the open refuses a camera that is not the one you meant.
It is not required, though, and leaving it out is the supported way to build an "add camera" box: an operator typing an address does not know the serial, and being told to go and find it is the flow the address exists to avoid. With network.address set and serial empty, the SDK sends one unicast probe to that address, takes the serial of whatever answers, and opens that camera. The check is not skipped (the open still names a serial); it is answered by the camera instead of by you. Nothing answering within network.discovery_timeout throws DeviceException naming the address. To do the probe without opening anything, call ProbeNetworkDevice(), which returns a full DeviceInfo and claims nothing.
kNetwork never falls back to USB
A camera asked for over Ethernet is never opened over USB instead. A camera plugged into USB and asked for over Ethernet is refused with an error saying where it was found instead, rather than opening the USB side and reporting success. Those are different connections with different behaviour, and the caller had already said which one it wanted.
A wrong address fails in seconds. network.connect_timeout (5 s by default) bounds the whole control bring-up, retries included. The same bound is reachable from every open that takes options; see How long before an open gives up.
The C forms
The last two forms are optris_sdk_imager_create_from_device() for an enumerated camera and optris_sdk_imager_create_network() with an optris_sdk_network_target, whose serial and address fields behave exactly as above. Each has a _with_options variant taking optris_sdk_camera_options.
The first form (name a serial and let the SDK decide the transport) has no C counterpart. optris_sdk_camera_options carries no serial, so optris_sdk_imager_create_with_options() opens the first camera found rather than a named one. From C, reach a specific camera by enumerating and passing the optris_sdk_device_info you want, or name its address in an optris_sdk_network_target.
optris_sdk_probe_network() is the C form of a unicast probe.
Network Configuration
Before using an Ethernet device, configure its network settings. You need:
- Device IP address: the IP the device assigns to itself.
- Destination IP and port: where the device sends its data stream (your machine).
- Subnet mask: the network subnet.
Configure via Imager::Device().SetNetworkConfig(), the otc_net tool that ships with the SDK, or the PixConnect tool. Over USB, otc_net is the supported way to move a camera onto a network:
otc_net show -s 26074397 otc_net set -s 26074397 --ip 10.0.0.21 --subnet 255.255.248.0 \ --stream-to 10.0.1.20 --port 50101
Set the mask, not only the address
Match the host's. A camera has no default gateway: it can only answer a host inside its own subnet. Moving a camera to a new address while leaving the factory 255.255.255.0 behind is what strands it, and recovering from that needs a USB cable.
Warning: A mask that is merely wrong rather than fatal is the most confusing failure here. Discovery is a directed broadcast to the host's own subnet broadcast address. If the camera's mask differs from the host's, that address is not the camera's broadcast address either, so the camera's stack discards the datagram, while unicast keeps working perfectly. The camera answers ping, accepts a TCP control connection, streams happily when opened by address, and is completely invisible to EnumerateDevices(). If discovery misses a camera that ping reaches, compare the masks before suspecting anything else. A camera whose discovery record has version 1001 is the exception: discovery also sends its request to the limited broadcast 255.255.255.255, which such a camera accepts in any subnet, and it answers by broadcast, so it is found even with a wrong mask or an address in another subnet, and can then be given a new address by broadcast. That request goes out of every network card of the computer, each copy on its own card, so it needs no default route and reaches every segment the computer is on. On Linux the camera's answer must also get past the computer's reverse-path filter: on a computer with no default route, the usual setting (rp_filter 1 or 2, the default of most distributions) discards an answer from a subnet the computer has no route to. A route for the camera's subnet on that card is enough, without a gateway, for example ip route add 10.0.0.0/20 dev eth1; measured with an Xi 640 ETH at 10.0.2.213/20 and a computer at 192.168.77.10/24.
otc_net takes --address for exactly this case, so a camera that discovery cannot see can still be reached and corrected over the network:
otc_net show -s 26074397 --address 10.0.0.21 otc_net set -s 26074397 --address 10.0.0.21 --subnet 255.255.240.0
The stream destination looks after itself
The address a camera sends its frames to is rewritten on every connect to whichever host interface actually reached it, so it does not have to be right in advance and does not need changing when a camera moves to another host. On a machine with several interfaces on one segment it will follow whichever the kernel routes through, and that is not a fault.
There is no DHCP, and no gateway
There is no DHCP on the device, and DeviceNetworkConfig carries neither a DHCP flag nor a gateway. The destination field is stream_destination, which is what the camera actually stores. The one place a gateway can be given is a setting by broadcast, on a camera that takes one.
Attention: Only static IP addresses are supported. Take care not to assign duplicate IPs. A camera whose discovery record has version 1001 can be given a new address by broadcast even when its present address is wrong or unknown, see below. Any other camera with a completely faulty network configuration can only be corrected by connecting it via USB.
Setting an address by broadcast
A camera with a wrong or unknown address cannot be opened, so it cannot be told a new address the ordinary way. A setting by broadcast is addressed by the camera's MAC address instead. Every camera on the network segment hears it, only the camera with that MAC address acts on it, and that camera answers by broadcast, so its answer reaches this host whatever subnet the camera is in. Nothing is opened and no camera is claimed. A broadcast does not cross a router: the camera has to be on the same network segment as this host.
Which cameras understand it. Every discovery reply carries a record version. Version 1001 means the camera answers discovery by broadcast and takes a setting by broadcast; version 1000 means it does neither. A camera can also have been told by its owner to refuse a setting by broadcast, which it says in the same record. GetNetworkDiscoveryInfo() returns that record, with the MAC address, for any camera this process has heard answer discovery:
optris::sdk::EnumerationOptions options; options.include_network = true; for (const auto &device : optris::sdk::EnumerateDevices(options)) { if (const auto info = optris::sdk::GetNetworkDiscoveryInfo(device.serial)) { std::printf("%s MAC %s version %u %s\n", info->serial.c_str(), info->mac_address.c_str(), info->protocol_version, info->accepts_broadcast_config ? "accepts" : "does not accept"); } }
optris_sdk_network_discovery_info info; int found = 0; optris_sdk_network_discovery_info_init(&info, sizeof(info)); optris_sdk_get_network_discovery_info("26094201", &info, &found); if (found) { printf("MAC %s version %u %s\n", info.mac_address, (unsigned)info.protocol_version, info.accepts_broadcast_config ? "accepts" : "does not accept"); }
NetworkDiscoveryInfo? info = Sdk.GetNetworkDiscoveryInfo("26094201"); if (info is not null) { Console.WriteLine($"MAC {info.MacAddress} version {info.ProtocolVersion} " + (info.AcceptsBroadcastConfig ? "accepts" : "does not accept")); }
info = optris_sdk.get_network_discovery_info('26094201') if info is not None: print(info.mac_address, info.protocol_version, 'accepts' if info.accepts_broadcast_config else 'does not accept')
if let Some(info) = optris_sdk::get_network_discovery_info("26094201")? { println!( "MAC {} version {} {}", info.mac_address, info.protocol_version, if info.accepts_broadcast_config { "accepts" } else { "does not accept" } ); }
Then send the setting. Give the MAC address, the new address and the mask, and a gateway if the camera needs one. By default the camera stores the setting and keeps its present address until it next starts, which is the recommended way: the camera answers from where it is, and nothing changes under a program that has it open. With immediately set it switches at once, after answering.
optris::sdk::BroadcastNetworkConfig config; config.mac_address = "9C:43:1E:70:40:3E"; config.ip_address = "10.0.2.213"; config.subnet_mask = "255.255.240.0"; // gateway empty: none const auto reply = optris::sdk::ConfigureNetworkByBroadcast(config); if (reply.status == optris::sdk::BroadcastConfigStatus::kTaken) { std::printf("taken, %s\n", optris::sdk::ToString(reply.effect)); } else { std::printf("%s\n", optris::sdk::ToString(reply.status)); }
optris_sdk_broadcast_network_config config; optris_sdk_broadcast_network_reply reply; optris_sdk_broadcast_network_config_init(&config, sizeof(config)); strncpy(config.mac_address, "9C:43:1E:70:40:3E", sizeof(config.mac_address) - 1); strncpy(config.ip_address, "10.0.2.213", sizeof(config.ip_address) - 1); strncpy(config.subnet_mask, "255.255.240.0", sizeof(config.subnet_mask) - 1); optris_sdk_broadcast_network_reply_init(&reply, sizeof(reply)); if (optris_sdk_configure_network_by_broadcast(&config, &reply) == OPTRIS_SDK_OK && reply.status == OPTRIS_SDK_BROADCAST_CONFIG_TAKEN) { printf("taken, the camera reports %s\n", reply.camera.address); }
BroadcastNetworkReply reply = Sdk.ConfigureNetworkByBroadcast(new BroadcastNetworkConfig { MacAddress = "9C:43:1E:70:40:3E", Address = "10.0.2.213", SubnetMask = "255.255.240.0", // Gateway empty: none }); Console.WriteLine(reply.Status == BroadcastConfigStatus.Taken ? $"taken, {reply.Effect}" : reply.Status.ToString());
reply = optris_sdk.configure_network_by_broadcast( '9C:43:1E:70:40:3E', '10.0.2.213', '255.255.240.0') print(reply.status.name, reply.effect.name)
let reply = optris_sdk::configure_network_by_broadcast( &optris_sdk::BroadcastNetworkConfig::new("9C:43:1E:70:40:3E", "10.0.2.213", "255.255.240.0"), )?; println!("{:?} {:?}", reply.status, reply.effect);
The camera checks the values and says what it did. Every answer except taken means nothing was stored:
| Status | Meaning |
|---|---|
| taken | Stored. The effect says whether it is active already or from the camera's next start. The answer carries the new address. |
| not plausible | The mask is 0 or not contiguous, the address is the network or broadcast address of its own mask, a class D or E address or in 127.0.0.0/8, or the gateway is outside the subnet. The camera does not say which. |
| not possible | The camera understood the request but cannot do what it asks. |
| refused | The camera has been told to refuse a setting by broadcast. That is switched on and off only over the camera's USB connection. |
| no answer | No camera with that MAC address answered. It is not on this network segment, it cannot be configured by broadcast (version 1000), or every request and every answer was lost. |
Except for taken, the answer carries the address the camera kept, so an answer is also a fresh discovery record. The request is repeated with the same request id until an answer arrives or the timeout runs out; a camera that hears it twice applies it twice, which changes nothing. The answer carries neither the mask nor the gateway.
examples/<language>/discovery/set_address_by_broadcast lists the cameras with --list and sends a setting when given a MAC address, an address and a mask. Run without arguments, it sends nothing.
Reading it, and writing it back
The configuration a camera holds is readable from an open camera, and writing takes a whole configuration rather than one field, so read the current one and change what you mean to change.
// Throws FeatureNotSupportedException on a USB camera, which has no // Ethernet interface to read. .NET answers null for the same case. const auto net = imager->Device().GetNetworkConfig(); std::println("{}/{} streaming to {}:{}", net.ip_address, net.subnet_mask, net.stream_destination, net.port);
optris_sdk_device_network_config net; optris_sdk_device_network_config_init(&net, sizeof(net)); /* OPTRIS_SDK_ERROR_NOT_SUPPORTED on a USB camera, which has no * Ethernet interface to read. */ if (optris_sdk_imager_get_network_config(imager, &net) == OPTRIS_SDK_OK) { printf("%s/%s streaming to %s:%u\n", net.ip_address, net.subnet_mask, net.stream_destination, (unsigned)net.port); }
if (camera.NetworkConfiguration is { } net) { Console.WriteLine($"{net.Address}/{net.SubnetMask} " + $"streaming to {net.StreamDestination}:{net.Port}"); } else { // A USB camera. Hide the network dialog. }
try: net = camera.network_config() print(f"{net.ip_address}/{net.subnet_mask} " f"streaming to {net.stream_destination}:{net.port}") except optris_sdk.NotSupportedError: pass # A USB camera. Hide the network dialog.
match camera.network_config() { Ok(net) => println!("{}/{} streaming to {}:{}", net.ip_address, net.subnet_mask, net.stream_destination, net.port), Err(e) if e.status() == Status::NotSupported => { // A USB camera. Hide the network dialog. } Err(e) => eprintln!("{e}"), }
A camera with no Ethernet interface answers absent rather than failing: that is every camera on USB and the simulated one, and it is an ordinary answer. A camera that has an interface whose settings could not be read throws instead, so "no interface" and "could not be read" are never confused for one another.
using optris::sdk::NetworkConfigOutcome; auto wanted = imager->Device().GetNetworkConfig(); wanted.ip_address = "10.0.0.42"; switch (imager->Device().SetNetworkConfig(wanted)) { case NetworkConfigOutcome::kAppliedConnectionKept: // An address-only change: the SDK followed the camera and this // imager still works. Re-read the address if you display it. break; case NetworkConfigOutcome::kAppliedConnectionLost: // Written, and the camera has moved out of reach. Destroy this // imager and open the camera again at its new address. break; case NetworkConfigOutcome::kUnchanged: // It already had these settings. Nothing was written. break; case NetworkConfigOutcome::kAppliedPendingEthernet: // Written over USB. Stored in the camera, not in effect yet. break; }
optris_sdk_device_network_config wanted; optris_sdk_network_apply_result outcome; optris_sdk_device_network_config_init(&wanted, sizeof(wanted)); optris_sdk_imager_get_network_config(imager, &wanted); strncpy(wanted.ip_address, "10.0.0.42", sizeof(wanted.ip_address) - 1); if (optris_sdk_imager_apply_network_config(imager, &wanted, &outcome) == OPTRIS_SDK_OK) { switch (outcome) { case OPTRIS_SDK_NETWORK_APPLIED_CONNECTION_KEPT: /* The SDK followed the camera; this imager still works. */ break; case OPTRIS_SDK_NETWORK_APPLIED_CONNECTION_LOST: /* Written, and the camera has moved out of reach. */ break; case OPTRIS_SDK_NETWORK_UNCHANGED: /* It already had these settings. Nothing was written. */ break; case OPTRIS_SDK_NETWORK_APPLIED_PENDING_ETHERNET: /* Written over USB. Stored, not in effect yet. */ break; default: break; } }
if (camera.NetworkConfiguration is { } current) { NetworkConfigurationOutcome outcome = camera.ApplyNetworkConfiguration(current with { Address = "10.0.0.42" }); switch (outcome) { case NetworkConfigurationOutcome.AppliedConnectionKept: // An address-only change: the SDK followed the camera and // this instance still works. Re-read the address if you // display it; your copy is stale now. break; case NetworkConfigurationOutcome.AppliedConnectionLost: // Written, and the camera has moved out of reach. This // instance is talking to nothing now; dispose it and open // the camera again at its new address. camera.Dispose(); break; case NetworkConfigurationOutcome.Unchanged: // It already had these settings. Nothing was written and // nothing on the network moved. break; case NetworkConfigurationOutcome.AppliedPendingEthernet: // Written over USB. Stored in the camera, not in effect: // it still answers on its old address for now. break; } }
wanted = camera.network_config() wanted.ip_address = '10.0.0.42' outcome = camera.apply_network_config(wanted) if outcome == optris_sdk.NETWORK_APPLIED_CONNECTION_KEPT: pass # The SDK followed the camera; this handle still works. elif outcome == optris_sdk.NETWORK_APPLIED_CONNECTION_LOST: camera.close() # Reopen at the new address. elif outcome == optris_sdk.NETWORK_UNCHANGED: pass # It already had these settings. Nothing was written. elif outcome == optris_sdk.NETWORK_APPLIED_PENDING_ETHERNET: pass # Written over USB. Stored, not in effect yet.
let mut wanted = camera.network_config()?; wanted.ip_address = "10.0.0.42".to_string(); match camera.apply_network_config(&wanted)? { NetworkApplyResult::AppliedConnectionKept => { // The SDK followed the camera; this handle still works. } NetworkApplyResult::AppliedConnectionLost => { drop(camera); // Reopen at the new address. } NetworkApplyResult::Unchanged => { // It already had these settings. Nothing was written. } NetworkApplyResult::AppliedPendingEthernet => { // Written over USB. Stored, not in effect yet. } }
What SetNetworkConfig() returns, and what it does not mean
The call returns a NetworkConfigOutcome, and which value you get is decided by which fields changed, not by how drastic the change looks:
| What changed | Outcome | What it means |
|---|---|---|
ip_address and/or port, nothing else |
kAppliedConnectionKept |
Written. The handle still works, at the new address. |
stream_destination or subnet_mask |
kAppliedConnectionLost |
Written. Close the imager and reopen. |
| Nothing: the configuration already matched | kUnchanged |
Nothing was written. |
| Anything, over a USB connection | kAppliedPendingEthernet |
Written, and not in effect yet. |
| An in-place reconnect that then failed | kAppliedConnectionLost |
Written. Close the imager and reopen. |
An address change keeps the connection
Moving the camera to a new address does not end the connection. The SDK reopens the control channel and the frame stream at the new address itself and hands the working Imager back, so an address-only change returns kAppliedConnectionKept. It means "still yours, at the new address", not "the address did not take"; closing the imager on it throws away a live camera and a stream that then has to be rebuilt. Re-read the address if you display it, because that is the one outcome after which your cached copy is stale. Only a new stream_destination or subnet_mask, or a failed in-place reconnect, gives kAppliedConnectionLost.
kUnchanged and kAppliedPendingEthernet
These two are the easy ones to miss. An identical configuration is skipped entirely, so nothing on the network changed and nothing should be logged as though it had. Over USB the settings are stored in the camera but are not in effect: it goes on answering on its old address until it is next reached over Ethernet, so a program that immediately goes looking for it at the new address will not find it.
The four answers need four different responses, so write your switch against every case in the table above, and in particular do not treat "the address changed" as a lost connection: the camera is still streaming.
Refusal is an exception, and the refusal is usually ours. stream_destination must differ from ip_address; the SDK checks that and throws DeviceException before anything is written, so the camera is never asked and never sees those settings. Do not report it to an operator as the camera refusing the configuration: an error message saying so is wrong about who refused and about whether the camera was even asked.
When the camera refuses
Some cameras check a configuration themselves and can say no. The Xi 640 ETH, reached over USB with firmware that reports revision 4200, answers every write with a verdict: it takes the values, or it refuses them with a reason and keeps what it had. A refused configuration is never stored.
RequestNetworkConfig() is the same write as SetNetworkConfig(), with the same checks before anything is sent and the same four outcomes when it is taken. The difference is that the camera's refusal comes back as a value, a NetworkConfigReply, with the reason and the configuration the camera kept. SetNetworkConfig() reports the same refusal as a DeviceException whose message names the reason.
| Reason | What the camera checked |
|---|---|
kSubnetMask |
The mask is 0 or not contiguous, such as 255.0.255.0. |
kAddress |
The address is 0, the network or broadcast address of its own mask, a class D or E address, or in 127.0.0.0/8. |
kGateway |
A gateway stored in the camera does not fit the new network. This configuration has no gateway field, so it cannot fix that. |
kDestinationAndPort |
The stream destination and the port must be both 0 or both set. |
kReservedPort |
The port is 9999, which carries the camera's own image stream. |
kOther |
A reason this SDK does not name; refusal_code holds the camera's number. |
On the Xi 640 ETH the address and mask take effect at the camera's next start, so the outcome over USB is kAppliedPendingEthernet. Its stream destination and port are the ones PIX Connect's stream uses; the camera's own image stream on UDP 9999 does not move with them.
An Xi 640 ETH reports these settings only over its USB connection. Opened over Ethernet, GetNetworkConfig() and RequestNetworkConfig() refuse with FeatureNotSupportedException (OPTRIS_SDK_ERROR_NOT_SUPPORTED in C, null from NetworkConfiguration in .NET, NotSupportedError in Python, Status::NotSupported in Rust), the same answer a camera with no Ethernet interface gives, and the message says what works instead. Over Ethernet, GetNetworkDiscoveryInfo() has the camera's address, MAC address and stream destination as it reported them when it was found, and a setting by broadcast changes its address.
optris::sdk::DeviceNetworkConfig wanted; wanted.ip_address = "10.0.2.213"; wanted.subnet_mask = "255.255.240.0"; wanted.stream_destination = "10.0.1.37"; wanted.port = 50101; const auto reply = imager->Device().RequestNetworkConfig(wanted); if (!reply.accepted) { // The camera refused and stored nothing. camera_config is what it kept. std::cout << "refused: " << optris::sdk::ToString(reply.refusal) << "\n"; }
optris_sdk_device_network_config wanted; optris_sdk_network_config_reply reply; optris_sdk_device_network_config_init(&wanted, sizeof(wanted)); strncpy(wanted.ip_address, "10.0.2.213", sizeof(wanted.ip_address) - 1); strncpy(wanted.subnet_mask, "255.255.240.0", sizeof(wanted.subnet_mask) - 1); strncpy(wanted.stream_destination, "10.0.1.37", sizeof(wanted.stream_destination) - 1); wanted.port = 50101; optris_sdk_network_config_reply_init(&reply, sizeof(reply)); if (optris_sdk_imager_request_network_config(imager, &wanted, &reply) == OPTRIS_SDK_OK && !reply.accepted) { /* Refused by the camera; nothing stored. reply.camera_config is what * it kept, and reply.refusal says why. */ }
NetworkConfigurationReply reply = camera.RequestNetworkConfiguration( new NetworkConfiguration("10.0.2.213", "255.255.240.0", "10.0.1.37", 50101)); if (!reply.Accepted) { // Refused by the camera; nothing stored. Console.WriteLine($"refused: {reply.Refusal}, the camera keeps " + $"{reply.CameraConfiguration.Address}"); }
reply = camera.request_network_config(optris_sdk.NetworkConfig( ip_address='10.0.2.213', subnet_mask='255.255.240.0', stream_destination='10.0.1.37', port=50101)) if not reply.accepted: # Refused by the camera; nothing stored. print('refused:', optris_sdk.network_refusal_name(reply.refusal))
let reply = camera.request_network_config(&NetworkConfig { ip_address: "10.0.2.213".to_string(), subnet_mask: "255.255.240.0".to_string(), stream_destination: "10.0.1.37".to_string(), port: 50_101, })?; if !reply.accepted { // Refused by the camera; nothing stored. println!("refused: {:?}", reply.refusal); }
The whole program, in every binding, is the device_control/network_config example: it reads the configuration, and writes only when given --set. It looks for the serial on USB first and then on the network, and for an Xi 640 ETH on Ethernet it prints what the camera said when it was found.
Firewall requirements on the host
On the host machine:
- Outgoing TCP to
<Device IP>:2000(control channel). - Incoming UDP from
<Device IP>on the port that camera streams to (streaming channel). The Xi 640 ETH uses 9999 for frames and 9998 for status instead; every other camera uses its configured destination port, 50101 from the factory.
Warning: On Windows the inbound rule is not optional and its absence looks like a broken camera, not a blocked port. The camera is found by discovery, the control connection succeeds, the model and video format are read correctly, and then no frame ever arrives; the SDK reports only "No frame data from ... for more than 10000 ms" and a connection status of Stalled. Windows Defender Firewall blocks unsolicited inbound UDP by default, so a rule is needed before any camera will stream.
Write the rule for the program, not for the port
One rule for the program covers every camera the application receives from, on every port, including a port changed later and the Xi 640 ETH's:
New-NetFirewallRule -DisplayName "Optris camera streams (MyApp)" -Direction Inbound ` -Action Allow -Protocol UDP -Program "C:\Path\To\MyApp.exe"
A per-port rule is the alternative, and it needs maintaining:
New-NetFirewallRule -DisplayName "Optris SDK camera stream" -Direction Inbound ` -Action Allow -Protocol UDP -LocalPort 50101 -RemoteAddress <Device IP>
Warning: A port rule stops matching the moment a camera moves. It covers one port and one camera's address, so a second camera needs a second rule, and the advice below, to give that camera a port of its own, takes it straight back outside the rule. The camera then shows exactly the symptom above: it opens, reports Connected, and never delivers a frame. If the port was changed with DeviceControl::SetNetworkConfig() on a running camera the SDK even reports kAppliedConnectionKept for it, because from the camera's side the change did succeed. Every otc_net set --port needs the rule updated, or a port range wide enough to cover all of them. A program rule has none of this.
Note: The dialog Windows shows the first time a program listens is not a substitute. It creates a rule only for the network categories ticked in it, and a camera link without a gateway is typically an unidentified network in the Public category, which that dialog does not tick by default, so clicking "Allow" can still leave the stream blocked. (Standard Windows Defender Firewall behaviour; worth confirming on a clean machine, which has not been done here.)
An application's own installer is where its rule belongs
The SDK installer adds no firewall rule, deliberately: opening an inbound port is a decision about the machine, not about the SDK. The example binaries it installs (examples\bin\simpleView.exe and the command-line tools) therefore meet the same wall on a fresh Windows machine as any other program, and need the rule above with their own path. The viewers open a network camera when you name its serial number, for example simpleView 26094201, or with --network; see Example Applications.
Give each camera its own port
Every camera leaves the factory streaming to port 50101, and the port is part of the camera's configuration, not the application's; ImagerConfig::network.port cannot be used to keep two cameras apart, because a camera that answers the address probe overrides it with its own. Two cameras pointed at one host therefore both send to the same port, where one SDK instance is bound expecting datagrams of one particular size, and neither camera works properly. Use otc_net set --port to give the second camera a different one, or DeviceControl::SetNetworkConfig() on a camera that is already open, where a port-only change keeps the connection.
The SDK refuses the second camera rather than letting it break the first. Opening a camera whose port another camera in this process is already receiving on throws DeviceException, naming the port, the serial number of the camera that holds it and both remedies. And neither camera is touched. In particular the second camera's stream is not re-pointed at this host first: on Windows a datagram larger than the receiving camera's own packet size makes recvfrom fail outright and the frame being assembled is thrown away, so re-pointing it would stop the first camera delivering frames. A port held by a camera in another process cannot be seen from here; that one surfaces as a bind failure during the open, which names the port but not the holder.
This bites harder than it sounds because a camera keeps streaming after the program that started it goes away: there is no handshake and no timeout, so a crashed or killed application leaves the camera hosing datagrams at that host indefinitely, and the next application to run there, even one opening a different camera, is the one that appears broken.
Control
The SDK establishes a TCP connection to port 2000 on the device. The firmware accepts one TCP connection at a time; additional connection attempts are refused. If a previous connection was not shut down gracefully, the SDK attempts automatic repair; if that fails, a power cycle is required.
Streaming
The device sends raw thermal data as UDP packets to the configured destination socket. A single thermal frame typically spans multiple UDP packets, which the SDK reassembles.
For network requirements, see the Optris technical note: Network Requirements for Optris Imager in Industrial Applications.