mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-10-01 03:43:46 +08:00
openpilot v0.8.8 release
This commit is contained in:
@@ -445,9 +445,10 @@ void hardware_control_thread() {
|
||||
if (sm.updated("driverCameraState")) {
|
||||
auto event = sm["driverCameraState"];
|
||||
int cur_integ_lines = event.getDriverCameraState().getIntegLines();
|
||||
float cur_gain = event.getDriverCameraState().getGain();
|
||||
|
||||
if (Hardware::TICI()) {
|
||||
cur_integ_lines = integ_lines_filter.update(cur_integ_lines);
|
||||
cur_integ_lines = integ_lines_filter.update(cur_integ_lines * cur_gain);
|
||||
}
|
||||
last_front_frame_t = event.getLogMonoTime();
|
||||
|
||||
|
||||
@@ -11,8 +11,10 @@
|
||||
#include "selfdrive/common/swaglog.h"
|
||||
#include "selfdrive/common/util.h"
|
||||
|
||||
Panda::Panda() {
|
||||
Panda::Panda(std::string serial) {
|
||||
// init libusb
|
||||
ssize_t num_devices;
|
||||
libusb_device **dev_list = NULL;
|
||||
int err = libusb_init(&ctx);
|
||||
if (err != 0) { goto fail; }
|
||||
|
||||
@@ -22,8 +24,28 @@ Panda::Panda() {
|
||||
libusb_set_debug(ctx, 3);
|
||||
#endif
|
||||
|
||||
dev_handle = libusb_open_device_with_vid_pid(ctx, 0xbbaa, 0xddcc);
|
||||
if (dev_handle == NULL) { goto fail; }
|
||||
// connect by serial
|
||||
num_devices = libusb_get_device_list(ctx, &dev_list);
|
||||
if (num_devices < 0) { goto fail; }
|
||||
for (size_t i = 0; i < num_devices; ++i) {
|
||||
libusb_device_descriptor desc;
|
||||
libusb_get_device_descriptor(dev_list[i], &desc);
|
||||
if (desc.idVendor == 0xbbaa && desc.idProduct == 0xddcc) {
|
||||
libusb_open(dev_list[i], &dev_handle);
|
||||
if (dev_handle == NULL) { goto fail; }
|
||||
|
||||
unsigned char desc_serial[25];
|
||||
int ret = libusb_get_string_descriptor_ascii(dev_handle, desc.iSerialNumber, desc_serial, sizeof(desc_serial));
|
||||
if (ret < 0) { goto fail; }
|
||||
|
||||
if (serial.empty() || serial.compare(reinterpret_cast<const char*>(desc_serial)) == 0) {
|
||||
break;
|
||||
}
|
||||
libusb_close(dev_handle);
|
||||
dev_handle = NULL;
|
||||
}
|
||||
}
|
||||
libusb_free_device_list(dev_list, 1);
|
||||
|
||||
if (libusb_kernel_driver_active(dev_handle, 0) == 1) {
|
||||
libusb_detach_kernel_driver(dev_handle, 0);
|
||||
@@ -47,6 +69,9 @@ Panda::Panda() {
|
||||
|
||||
fail:
|
||||
cleanup();
|
||||
if (dev_list != NULL) {
|
||||
libusb_free_device_list(dev_list, 1);
|
||||
}
|
||||
throw std::runtime_error("Error connecting to panda");
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class Panda {
|
||||
void cleanup();
|
||||
|
||||
public:
|
||||
Panda();
|
||||
Panda(std::string serial="");
|
||||
~Panda();
|
||||
|
||||
std::atomic<bool> connected = true;
|
||||
|
||||
Reference in New Issue
Block a user