The camera drops mid-shift and the console fills with lines like Command sending error: Not connected, while your acquisition loop keeps calling grab on a device that no longer exists. That is the standard failure mode of a USB3 Vision camera losing its link, and it is recoverable in software if your code treats the drop as an event rather than a surprise. Here you will read the warning correctly, work down the six usual causes with a one-minute test for each, and write a recovery loop that closes the dead device, re-enumerates the bus, reopens by serial number and restarts the stream without stopping the program or the line. The worked example shows the bandwidth arithmetic that separates a real drop from a host controller that never had the capacity.
What the warning actually tells you
The console line [UvDevice::read_memory] Command sending error: Not connected decomposes into three facts. UvDevice::read_memory is the library's USB3 Vision control-layer call, a GenICam register read; exposure readbacks, temperature polls and the library's own heartbeat all walk through it many times per second. The command-send failure is the transport dying, and the not-connected part is the operating system reporting that the pipe to the camera is gone.
A USB3 Vision camera runs two channels over one cable: a control endpoint carrying register traffic and a bulk stream endpoint carrying image data. When the control endpoint dies, the stream dies with it or stalls mid-frame without a clean error. That silent stall is the frozen-stream failure; the frozen camera stream alarm walkthrough builds the watchdog for it.
The distinction that matters: the warning comes from the library's logger, not from your thread. Your catch block stays silent because the library logs rather than raises; the exception only arrives later, when the grab call itself finally fails. Handle both ends: set the library's log level to errors-only in production, which every GenICam stack exposes, and treat the grab failure as the event your recovery reacts to. Keep the log lines in a file rather than deleting them; their timestamps mark exactly when each drop began.
Likely causes, in order of probability
Work down this list; each item has a one-minute test.
- Cable and connector. By far the most common: a loose latch, a jacket rubbed through by a drag chain, a cable never rated for flex at all. Test: stream at full rate and wiggle the cable at both ends, 20 times; drops that track the wiggle are yours. Fix: a flex- or drag-chain-rated USB3 cable with strain relief, cut to the motion. If the camera never enumerates again at all, continue with the host-path walkthrough for a USB camera that will not enumerate.
- The port fell back from SuperSpeed to high speed. A damaged SuperSpeed pair inside an otherwise working cable, a USB2-only port or an old hub leaves the camera enumerated at 480 Mbit/s. Code still sees a device; the stream just cannot keep up. Test: read the negotiated speed in the host's device manager or system log. On embedded boards this failure has its own playbook: embedded-host USB3 camera fallback troubleshooting.
- Power. A SuperSpeed port supplies up to 900 mA at 5 V, and a camera drawing more than that brown-outs when a second load joins the hub. Test: give the camera its own power connector and watch the drop count. Drops timed to a valve or contactor firing nearby are the classic signature.
- One host controller, too many cameras. Everything behind one controller shares its 5 Gbit/s link. Test: run each camera alone at full rate. Stable solo and dropping together means bandwidth; the two USB3 cameras at full resolution walkthrough covers the host-buffer side of a shared bus.
- Host buffer starvation. Low frame rate first, then a stall. On Linux the default usbfs memory caps the queued buffers; the USB3 low frame rate and usbfs memory fix walks that setting.
- Wedged control session. The device lists, but open and start-stream fail repeatedly. Replug rarely clears it; remove camera power for a few seconds instead. Driver-side conflicts after a faulted session wear the same face: driver-conflict recovery after a faulted USB3 session works through one SDK's version of it.
Worked example: 4000 × 3000 at 30 fps against the SuperSpeed budget
Before touching code, check the stream fits the link at all, because a bandwidth shortfall produces the same not-connected noise as a cut cable. Throughout this section MB means 1,000,000 bytes and Mbit/s means 1,000,000 bits per second.
| Input | Value | Source |
|---|---|---|
| Resolution | 4000 × 3000 px | catalog data sheet of the LS-CMR-0166 |
| Frame rate | 30 fps | catalog data sheet of the LS-CMR-0166 |
| Pixel data | 1 byte per pixel, 8-bit mono | assumed, the usual mono set-up |
| Link | USB 3.0, 5 Gbit/s raw | USB 3.0 specification |
| Encoding | 8b/10b, so 4 Gbit/s usable | USB 3.0 specification |
| Practical bulk payload | about 400 MB/s | typical USB3 Vision ceiling, about 20% overhead |
The rule: payload in MB/s equals width times height times frame rate times bytes per pixel, divided by 1,000,000. Keep the total behind one host controller at or below 90% of the practical budget.
The arithmetic:
- 4000 × 3000 = 12,000,000 pixels per frame.
- 12,000,000 px × 30 fps = 360,000,000 pixels per second.
- 360,000,000 px/s × 1 byte = 360 MB/s of payload.
- Budget: 5 Gbit/s × 0.8 = 4 Gbit/s usable; 4 Gbit/s ÷ 8 = 500 MB/s raw; planning figure 400 MB/s after overhead.
- Headroom: 400 − 360 = 40 MB/s, about 10%.
Decision: the stream fits a healthy SuperSpeed link with 10% to spare, so a drop on this camera is physical or host-side, not a capacity wall. Hold the 360 MB/s line per controller; above it, split cameras across controllers or change interface class.
The same camera on a port that negotiated high speed: 480 Mbit/s ÷ 8 = 60 MB/s raw, with practical bulk throughput near 35 MB/s. One frame is 12 MB, so 35 MB/s ÷ 12 MB gives about 2.9 fps against the 30 fps demanded — a tenfold deficit no code recovers. That is why a camera that enumerates fine and then storms not-connected within seconds points at cable and port before software. A 10 Gbit/s Gen 2 port roughly doubles both budgets.
The camera behind this example, the LS-CMR-0166, is a 12 MP USB3 area scan camera on a 1/1.7" sensor; it sits among the shop's USB3 area scan cameras, and the camera finder filters the range by interface and resolution.
- Sensor format
- 1/1.7"
- Interface
- USB3
- Resolution
- 12 MP
- Shutter
- Rolling
Catch the drop in your grab loop
Structure the loop around three states: streaming, reconnecting, alarmed. One watchdog covers the silent stall; one catch covers the loud failure.
// Illustrative pseudocode: call names differ by SDK. The four steps -
// grab with timeout, close, re-enumerate, reopen by serial - exist in
// every GenICam stack under its own names.
bool running = true; // set false by the shutdown handler
bool streaming = true; // true while frames should be arriving
int retries = 0; // failed re-enumeration attempts
int maxRetries = 5; // alarm threshold
int settleMs = 250; // pause after close before re-enumerating
uint64_t lastFrameMs = now(); // arrival time of the last good frame
while (running) {
if (streaming && now() - lastFrameMs > 100) { // 3 frame periods at 30 fps
forceClose(device); // release the dead handle first
streaming = false;
}
if (!streaming) {
sleep(settleMs);
if (deviceList.refresh().contains(serial)) {
device = openBySerial(serial); // serial, never index
applySavedSettings(); // exposure, gain, ROI
streaming = true;
log("reconnected after " + retries + " failed attempts");
retries = 0;
} else if (++retries > maxRetries) {
raiseAlarm("camera " + serial + " gone from the bus");
}
continue;
}
try {
frame = grab(1000); // 1000 ms stream timeout
process(frame);
lastFrameMs = now();
} catch (GrabError) {
streaming = false; // loud failure path
}
}
The 100 ms watchdog threshold is three frame periods at 30 fps (3 × 33 ms); scale it to your frame rate. Frames that keep arriving with old timestamps are the subtler half of the failure — detect a USB camera disconnected during acquisition from stale frames covers that pattern. If your loop crashes instead of raising an exception, the errno 19 crash fix for Python USB cameras is the worked version of the same bug.
Prove it on the bench before production: stream at full rate, pull the cable mid-run and plug it back. Pass is one log line per drop, no traceback, and live frames within a second of re-plug. Then repeat 20 times as a soak; the 20th cycle is where an unclosed handle finally leaks into a failed recovery.
Reopen without stopping the line
- Stop the stream and close the device handle. Releasing the dead handle stops the warnings stacking and frees the stack for re-enumeration.
- Wait 250-500 ms. The host tears the old device down asynchronously, and an instant refresh sometimes still returns the dying device's address.
- Refresh the device list and look for your serial number. Absent means still unplugged or still wedged; poll every 500 ms until it appears or the retry budget runs out.
- Match by serial number, never by index. Enumeration order shifts whenever a camera re-enumerates or a second head joins the bus, so the saved index can point at another camera.
- Reopen and re-apply the saved recipe: exposure, gain, ROI, pixel format. A fresh open starts from defaults, not from your settings.
- Confirm recovery before declaring it: negotiated speed back at SuperSpeed, and a first frame that passes a plausibility check — histogram not flat, expected part present.
- After five failed attempts, raise the operator alarm and switch the fallback to power: remove camera power for a few seconds and resume polling.
In a robot cell the same sequence runs without stopping the program; robot vision camera disconnect detection without stopping the program stages it that way. The GigE twin of this problem recovers by rediscovery rather than re-enumeration — see camera lost after a resource error: rediscovery and recovery.
Hardware that stops the drops before they start
Cables: keep each segment at about 3 m or less at SuperSpeed, the length USB 3.0 cabling is rated for at 5 Gbit/s; longer runs belong on active or optical cables, or a different interface. On a moving axis, use a cable rated for drag chains with strain relief at both ends. The shop's camera cables carry flex-rated options, and the accessories finder filters them by length and type. For a moving axis, this is the class to spec:
Power and hubs: prefer a camera with its own power connector wherever a drop costs a scrapped part. If a hub is unavoidable, use a powered unit that supplies the full 900 mA per port and keeps the SuperSpeed route intact. The enumerate-then-disconnect pattern of board-level USB-C ports is worked through in the USB3 hub disconnect walkthrough.
Host: in a fixed cell, short cables into one host beat long cables through hubs. The MV-VC2140-128G40-1T vision controller carries two USB 3 ports, four built-in light channels and 8 GB of memory on an Intel N97, so camera wiring and light wiring live in one enclosure. Browse the wider vision controllers range when you need more ports or PoE.
- LAN ports
- 3-4 LAN ports
- USB 3 ports
- 2 USB 3 ports
- Light outputs
- 4 built-in channels
- Memory
- 8 GB
Bench test before you ship it
- Stream at full resolution and frame rate for a full shift; a healthy cell holds zero unexplained drops, and anything above one per hour gets investigated before deployment.
- Pull the cable mid-run 20 times; require exactly one log line per drop and automatic recovery within a second of re-plug.
- Cut camera power once instead of pulling the cable; recovery must survive a wedged control session, which replug alone does not always clear.
- Cap the lens and watch the last-frame alarm fire at three frame periods — 100 ms at 30 fps; the alarm, not a hung timeout, is what reaches the operator.
- Re-check negotiated speed after every recovery; a recovery that silently lands on high speed fails within seconds of real traffic.
If the bench test pushes the decision toward hardware, the configurator steps through camera, cable and controller in order, and the systems topic page gathers the disconnect-and-recovery patterns around this one, from Python-side crashes to robot-cell recovery. For a cell with several heads and a mixed cable plan, contact the applications team with resolution, frame rate and motion profile, and the layout comes back sized to a per-controller payload budget rather than guessed.
Questions
How long should recovery wait between reconnect attempts?
Close the handle, then pause 250-500 ms before the first refresh, and poll every 500 ms after that. Faster, and the host sometimes still returns the dying device's address, which makes open succeed and fail in the same cycle. Slower wastes cycle time on a line that recovers in about a second anyway. Five attempts at that cadence covers a re-plug in under ten seconds.
Why does the console flood with warnings when my try/except catches nothing?
GenICam libraries log their own register housekeeping: a failed memory read inside the library prints a warning to the console independent of the exception your code receives. Filter that logger to errors-only in production and rely on the grab error as your trigger. Collect the log lines into a file rather than deleting them — their timestamps tell you exactly when each drop began.
How much bandwidth is left for a second USB3 camera on one controller?
One USB3 host controller shares its 5 Gbit/s link, with roughly 400 MB/s of practical bulk payload. Two 2 MP cameras at 60 fps need 138 MB/s each, so 277 MB/s total fits with margin. Two 4000 × 3000 cameras at 30 fps need 720 MB/s, double the budget: split them across separate host controllers. Run the arithmetic at your own resolution before assuming two fit.
The host lists the camera as high speed — is the camera broken?
Usually not the camera. High speed means the SuperSpeed pairs never trained: a damaged cable, a USB2-only port or an old hub in between. The camera still enumerates, so code sees a device, but a full-rate stream cannot sustain — at high speed's practical 35 MB/s, a 12 MB frame limits you to about 3 fps. Swap the cable first, then try a different root-hub port.


