Skip to content

Commit

Permalink
fix build problems and add is_stop() function
Browse files Browse the repository at this point in the history
  • Loading branch information
noacoohen committed Sep 16, 2024
1 parent a0c7df0 commit 3acb7b5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/libusb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ target_sources(${LRS_TARGET}

"${CMAKE_CURRENT_LIST_DIR}/device-watcher-libusb.cpp"
"${CMAKE_CURRENT_LIST_DIR}/device-watcher-libusb.h"

"${CMAKE_CURRENT_LIST_DIR}/libusb.h"
"${CMAKE_CURRENT_LIST_DIR}/libusb.h"
)
10 changes: 8 additions & 2 deletions src/libusb/device-watcher-libusb.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2019 Intel Corporation. All Rights Reserved.
// Copyright(c) 2024 Intel Corporation. All Rights Reserved.
#include "device-watcher-libusb.h"

#include "libusb.h"
#include "context-libusb.h"
#include <rsutils/string/string-utilities.h>

using namespace librealsense;
using namespace librealsense::platform;
Expand Down Expand Up @@ -68,7 +69,7 @@ void device_watcher_libusb::start(librealsense::platform::device_changed_callbac
if(rc)
LOG_ERROR("Error getting device descriptor " << libusb_error_name(rc));
else
LOG_INFO(event_str << " address: " << addr << " VID: " << hexify(desc.idVendor) << " PID: " << hexify(desc.idProduct));
LOG_INFO( event_str << " address: " << addr << " VID: "<< rsutils::string::hexify( desc.idVendor ) << " PID: " << rsutils::string::hexify( desc.idProduct ) );

// No querying or talking to devices in hotplug callback https://github.com/libusb/libusb/issues/408
((device_watcher_libusb *)user_data)->update_next = true;
Expand Down Expand Up @@ -110,3 +111,8 @@ void device_watcher_libusb::stop()
}
_callback = nullptr;
}

bool device_watcher_libusb::is_stopped() const
{
return _fallback_polling->is_stopped();
}
6 changes: 4 additions & 2 deletions src/libusb/device-watcher-libusb.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/* License: Apache 2.0. See LICENSE file in root directory. */
/* Copyright(c) 2019 Intel Corporation. All Rights Reserved. */
/* Copyright(c) 2024 Intel Corporation. All Rights Reserved. */
#pragma once

#include "../types.h"
#include "../backend.h"
#include "../usb/usb-device.h"
#include "libusb.h"
#include "context-libusb.h"

#include "../platform/device-watcher.h"
#include "../polling-device-watcher.h"
#include <memory>

namespace librealsense
Expand All @@ -20,6 +21,7 @@ namespace librealsense
device_watcher_libusb(const platform::backend* backend_ref);
virtual void start(device_changed_callback callback) override;
virtual void stop() override;
virtual bool is_stopped() const override;

private:
const platform::backend* _backend;
Expand Down
4 changes: 2 additions & 2 deletions src/libusb/enumerator-libusb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "libusb/device-libusb.h"
#include "context-libusb.h"
#include "types.h"

#include <rsutils/string/string-utilities.h>
#include "libusb.h"

namespace librealsense
Expand Down Expand Up @@ -93,7 +93,7 @@ namespace librealsense
auto ret = libusb_get_device_descriptor(device, &desc);
if (LIBUSB_SUCCESS == ret)
{
LOG_DEBUG("Found device " << hexify(desc.idVendor) << " " << hexify(desc.idProduct));
LOG_DEBUG( "Found device " << rsutils::string::hexify( desc.idVendor ) << " "<< rsutils::string::hexify( desc.idProduct ) );
auto sd = get_subdevices(device, desc);
rv.insert(rv.end(), sd.begin(), sd.end());
}
Expand Down

0 comments on commit 3acb7b5

Please sign in to comment.