got everything compiling (should still work too) with aos
diff --git a/gyro_board/src/libusb-driver/libusb_wrap.cc b/gyro_board/src/libusb-driver/libusb_wrap.cc
index 1f54998..d8161ab 100644
--- a/gyro_board/src/libusb-driver/libusb_wrap.cc
+++ b/gyro_board/src/libusb-driver/libusb_wrap.cc
@@ -1,12 +1,13 @@
-#include <libusb.h>
-#include <google/gflags.h>
-#include <glog/logging.h>
-#include <iostream>
-
#include "libusb_wrap.h"
+#include <iostream>
+
+#include "aos/common/logging/logging.h"
+
LibUSB::LibUSB() {
- CHECK_GE(libusb_init(&ctx_), 0) << ": LibUSB failed to initialize.";
+ if (libusb_init(&ctx_) < 0) {
+ LOG(FATAL, "libusb_init(%p) failed\n", &ctx_);
+ }
libusb_set_debug(ctx_, 3);
}
@@ -17,26 +18,30 @@
ssize_t cnt;
cnt = libusb_get_device_list(ctx_, &devs);
- if(cnt < 0) {
- LOG(ERROR) << "Get Device Error";
+ if (cnt < 0) {
+ LOG(ERROR, "Get Device Error\n");
return NULL;
}
- LOG(INFO) << cnt << " Devices in list.";
+ LOG(INFO, "%d Devices in list.\n", cnt);
bool found = false;
for (int i = 0; i < cnt; ++i) {
struct libusb_device_descriptor desc;
r = libusb_get_device_descriptor(devs[i], &desc);
- CHECK_GE(r, 0) << ": Couldn't get device descriptor, error " << r;
+ if (r < 0) {
+ LOG(FATAL, "lib_usb_get_device_descriptor(%p, %p) failed\n",
+ devs[i], &desc);
+ }
if (desc.idVendor == vid && desc.idProduct == pid) {
- LOG(INFO) << "Device " << (int)libusb_get_bus_number(devs[i]) << ":"
- << (int)libusb_get_device_address(devs[i]) << " matches";
+ LOG(INFO, "Device %d:%d matches\n",
+ (int)libusb_get_bus_number(devs[i]),
+ (int)libusb_get_device_address(devs[i]));
r = libusb_open(devs[i], &dev_handle);
if (libusb_kernel_driver_active(dev_handle, 0) == 1) {
- LOG(INFO) << "Device already in use, trying next one.";
+ LOG(INFO, "Device already in use, trying next one.");
continue;
}
if (r < 0) {
- LOG(WARNING) << "Failed to open device.";
+ LOG(WARNING, "Failed to open device.");
} else {
found = true;
break;
@@ -45,26 +50,26 @@
}
libusb_free_device_list(devs, 1);
if (!found) {
- LOG(ERROR) << "Couldn't open device.";
+ LOG(ERROR, "Couldn't open device.");
return NULL;
}
if (libusb_kernel_driver_active(dev_handle, 0) == 1) {
- LOG(INFO) << "Kernel Driver Active";
+ LOG(INFO, "Kernel Driver Active");
if (libusb_detach_kernel_driver(dev_handle, 0) == 0) {
- LOG(INFO) << "Kernel Driver Detached!";
+ LOG(INFO, "Kernel Driver Detached!");
} else {
- LOG(ERROR) << "Couldn't detach kernel driver.";
+ LOG(ERROR, "Couldn't detach kernel driver.");
return NULL;
}
}
r = libusb_claim_interface(dev_handle, 0);
if (r < 0) {
- LOG(ERROR) << "Cannot Claim Interface";
+ LOG(ERROR, "Cannot Claim Interface");
return 0;
}
- LOG(INFO) << "Claimed Interface";
+ LOG(INFO, "Claimed Interface");
return new LibUSBDeviceHandle(dev_handle);
}
@@ -79,9 +84,9 @@
int r;
r = libusb_release_interface(dev_handle_, 0);
if (r != 0) {
- LOG(FATAL) << "Cannot Release Interface";
+ LOG(FATAL, "Cannot Release Interface");
}
- LOG(INFO) << "Released Interface";
+ LOG(INFO, "Released Interface");
libusb_close(dev_handle_);
}