diff --git a/CMakeLists.txt b/CMakeLists.txt index 55bcc03150c58e384ab785a24dc6be0ea7b55186..8d14cad842dc23e00c67e6371d530047b4f3882f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ if(POLICY CMP0063) endif() project(jasonrec) -set(JASONREC_VERSION "1.0") +set(JASONREC_VERSION "1.1") add_definitions(-DJASONREC_VERSION="${JASONREC_VERSION}") find_path(LIBUSB_INCLUDE_DIR @@ -15,4 +15,3 @@ find_library(LIBUSB_LIBRARY PATH_SUFFIXES "lib" "lib32" "lib64") add_subdirectory(src) - diff --git a/src/recorder.cpp b/src/recorder.cpp index ae1a834d9f77bd347b61250a5a722407c348d6c4..8c5e33e8609d4c82275ab1021897965abce3347f 100644 --- a/src/recorder.cpp +++ b/src/recorder.cpp @@ -44,6 +44,7 @@ JasonRecorder::JasonRecorder() { JasonRecorder::~JasonRecorder() { // free handle if (handle) { + libusb_release_interface(handle, 0); libusb_close(handle); } // free devices @@ -60,6 +61,7 @@ size_t JasonRecorder::get_device_count() { void JasonRecorder::set_device(size_t number) { if (handle) { + libusb_release_interface(handle, 0); libusb_close(handle); handle = NULL; } @@ -69,6 +71,9 @@ void JasonRecorder::set_device(size_t number) { if (libusb_open(devices[number], &handle) < 0) { throw std::runtime_error("could not open USB device (try again as root)"); } + if (libusb_claim_interface(handle, 0) < 0) { + throw std::runtime_error("could not claim USB interface"); + } } void JasonRecorder::send_message(std::uint8_t cmd) {