Skip to content

Commit

Permalink
[cscore] Make camera connection logging clearer (wpilibsuite#5866)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzblue authored Nov 3, 2023
1 parent 87f7c19 commit 049732a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
6 changes: 5 additions & 1 deletion cscore/src/main/native/linux/UsbCameraImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ void UsbCameraImpl::DeviceConnect() {
}

if (m_connectVerbose) {
SINFO("Connecting to USB camera on {}", m_path);
SINFO("Attempting to connect to USB camera on {}", m_path);
}

// Try to open the device
Expand All @@ -606,6 +606,10 @@ void UsbCameraImpl::DeviceConnect() {
}
m_fd = fd;

if (m_connectVerbose) {
SINFO("Connected to USB camera on {}", m_path);
}

// Get capabilities
SDEBUG3("getting capabilities");
struct v4l2_capability vcap;
Expand Down
4 changes: 3 additions & 1 deletion cscore/src/main/native/objcpp/UsbCameraImplObjc.mm
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ - (bool)deviceConnect {
}

std::string pathStr = [self.path UTF8String];
OBJCINFO("Connecting to USB camera on {}", pathStr);
OBJCINFO("Attempting to connect to USB camera on {}", pathStr);

self.videoDevice = [AVCaptureDevice deviceWithUniqueID:self.path];
if (self.videoDevice == nil) {
Expand Down Expand Up @@ -594,6 +594,8 @@ - (bool)deviceConnect {
goto err;
}

OBJCINFO("Connected to USB camera on {}", pathStr);

[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(sessionRuntimeError:)
Expand Down
6 changes: 5 additions & 1 deletion cscore/src/main/native/windows/UsbCameraImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ bool UsbCameraImpl::DeviceConnect() {
}

if (m_connectVerbose) {
SINFO("Connecting to USB camera on {}", m_path);
SINFO("Attempting to connect to USB camera on {}", m_path);
}

SDEBUG3("opening device");
Expand All @@ -526,6 +526,10 @@ bool UsbCameraImpl::DeviceConnect() {
return false;
}

if (m_connectVerbose) {
SINFO("Connected to USB camera on {}", m_path);
}

CS_Status st = 0;
auto devices = EnumerateUsbCameras(&st);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void setConnectVerboseEnabledTest() {

assertTimeoutPreemptively(
Duration.ofSeconds(5),
() -> assertTrue(result.get().contains("Connecting to USB camera on ")));
() -> assertTrue(result.get().contains("Attempting to connect to USB camera on ")));
}
}

Expand Down

0 comments on commit 049732a

Please sign in to comment.