Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public String name() {
@Override
public String uniquePath() {
return Arrays.stream(super.otherPaths)
.sorted() // Must sort to ensure a consistent unique path as we can get more than one
// by-path and their order changes at random?
.filter(path -> path.contains("/by-path/"))
.findFirst()
.orElse(path());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public synchronized boolean assignUnmatchedCamera(PVCameraInfo cameraInfo) {
.equals(cameraInfo.uniquePath()))) {
logger.error(
"Camera unique-path already in use by active VisionModule! Cannot add " + cameraInfo);
return false;
}

var source = loadVisionSourceFromCamConfig(new CameraConfiguration(cameraInfo));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,47 @@ public void testEnabledDisabled() throws InterruptedException {
vsm.teardown();
}

@Test
public void testOtherPathsOrderChange() throws InterruptedException {
// GIVEN a VSM
var vsm = new TestVsm();
// AND one camera and camera config with flipped otherpaths order
var cam =
PVCameraInfo.fromUsbCameraInfo(
new UsbCameraInfo(
0,
"/dev/video0",
"Lifecam HD-3000",
new String[] {"/dev/v4l/by-path/usbv2/foobar1", "/dev/v4l/by-path/usb/foobar1"},
5940,
5940));

var camOtherPaths =
PVCameraInfo.fromUsbCameraInfo(
new UsbCameraInfo(
1,
"/dev/video1",
"Lifecam HD-3000",
new String[] {"/dev/v4l/by-path/usb/foobar1", "/dev/v4l/by-path/usbv2/foobar1"},
5940,
5940));
CameraConfiguration camOtherPathsConf = new CameraConfiguration(camOtherPaths);
camOtherPathsConf.nickname = "TestCamera";
camOtherPathsConf.deactivated = false;

vsm.registerLoadedConfigs(List.of(camOtherPathsConf));

vsm.assignUnmatchedCamera(cam);

assertEquals(0, vsm.getVsmState().disabledConfigs.size());
assertEquals(1, vsm.vmm.getModules().size());
assertEquals(cam.uniquePath(), camOtherPaths.uniquePath());

Thread.sleep(2000);

vsm.teardown();
}

@Test
public void testDuplicate() throws InterruptedException, IOException {
var fileCamera1 =
Expand Down