如何检测USRP usb类型?

How to detect USRP usb type?

当我在 main.cpp 中包含 uhd/usb_control.hpp 时:

#include <uhd/transport/usb_control.hpp>

/* Some other includes */

int main (void)
{
    uhd::transport::usb_control::sptr usbSpeed;

    usbSpeed = uhd::transport::usb_control::make(handle, 0);
    /* `handle` is a `usb_device_handle::vid_pid_pair_t` */
}

我从 here 收到错误:

static sptr make(usb_device_handle::sptr handle, const int interface);

错误:
意外的标记结构。你忘记了';'
结构:缺少标签名称

还有另一个奇怪的错误:

usbSpeed = uhd::transport::usb_control::make(handle, 0);

错误:
无法将参数 2 从 int 转换为 const int

我找到的 uhd::transport::usb_control::make 的唯一实现是 uhd/transport/usb_dummy_impl.cpp,它只会抛出异常。

Environment information:
Compiler: MS Visual Studio 2017
OS: MS Windows 10
C++ Standard: 17

如何解决这些错误?我只检测USRP usb类型。为此,我阅读了 uhd 源代码并找到了 uhd/transport/usb_control.hpp,但我遇到了这些错误。

也许这种意外行为的原因与您包含的文件以及其中一些文件之间的冲突有关,正如您提到的 #include <uhd/transport/usb_control.hpp> 除了您还有其他一些包含。我建议将此包含行移动到其他包含行的上方和下方,然后再次测试您的代码。

希望我的建议有用。