From 1fac8b47aaa3f59277f0e7f6bbb23f10294b1ded Mon Sep 17 00:00:00 2001 From: Aaron Cuevas Lopez Date: Mon, 16 Sep 2024 19:05:10 +0200 Subject: [PATCH] Fix oni calls crashing when no acquisition board is present --- Source/devices/oni/AcqBoardONI.cpp | 10 +++++----- Source/devices/oni/rhythm-api/rhd2000ONIboard.cpp | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/devices/oni/AcqBoardONI.cpp b/Source/devices/oni/AcqBoardONI.cpp index a5cfc2c..6f4f71b 100644 --- a/Source/devices/oni/AcqBoardONI.cpp +++ b/Source/devices/oni/AcqBoardONI.cpp @@ -77,14 +77,14 @@ bool AcqBoardONI::detectBoard() LOGC ("Searching for ONI Acquisition Board..."); const oni_driver_info_t* driverInfo; int return_code = evalBoard->open (&driverInfo); - - int major, minor, patch; - evalBoard->getONIVersion (&major, &minor, &patch); - LOGC ("ONI Library version: ", major, ".", minor, ".", patch); - LOGC ("ONI Driver: ", driverInfo->name, " Version: ", driverInfo->major, ".", driverInfo->minor, ".", driverInfo->patch, (driverInfo->pre_release ? "-" : ""), (driverInfo->pre_release ? driverInfo->pre_release : "")); + if (return_code == 1) // successfully opened board { + int major, minor, patch; + evalBoard->getONIVersion (&major, &minor, &patch); + LOGC ("ONI Library version: ", major, ".", minor, ".", patch); + LOGC ("ONI Driver: ", driverInfo->name, " Version: ", driverInfo->major, ".", driverInfo->minor, ".", driverInfo->patch, (driverInfo->pre_release ? "-" : ""), (driverInfo->pre_release ? driverInfo->pre_release : "")); if (evalBoard->getFTDriverInfo (&major, &minor, &patch)) { LOGC ("FTDI Driver version: ", major, ".", minor, ".", patch); diff --git a/Source/devices/oni/rhythm-api/rhd2000ONIboard.cpp b/Source/devices/oni/rhythm-api/rhd2000ONIboard.cpp index 5156920..493f938 100644 --- a/Source/devices/oni/rhythm-api/rhd2000ONIboard.cpp +++ b/Source/devices/oni/rhythm-api/rhd2000ONIboard.cpp @@ -36,10 +36,11 @@ bool Rhd2000ONIBoard::isUSB3() int Rhd2000ONIBoard::open (const oni_driver_info_t** driverInfo) { ctx = oni_create_ctx ("ft600"); // "ft600" is the driver name for the usb - if (driverInfo) - getONIDriverInfo (driverInfo); if (ctx == NULL) return -1; + if (driverInfo) + getONIDriverInfo (driverInfo); + if (oni_init_ctx (ctx, -1) != ONI_ESUCCESS) {