  int Panda::usb_write(uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned int timeout) {
    int err;
    const uint8_t bmRequestType = LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE;
  
    pthread_mutex_lock(&usb_lock);
    do {
      err = libusb_control_transfer(dev_handle, bmRequestType, bRequest, wValue, wIndex, NULL, 0, timeout);
      if (err < 0) handle_usb_issue(err, __func__);
 
</s>
  if (!connected){
    return LIBUSB_ERROR_NO_DEVICE;
  }

  int Panda::usb_write(uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned int timeout) {
    int err;
    const uint8_t bmRequestType = LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE;
  
  if (!connected){
    return LIBUSB_ERROR_NO_DEVICE;
  }

    pthread_mutex_lock(&usb_lock);
    do {
      err = libusb_control_transfer(dev_handle, bmRequestType, bRequest, wValue, wIndex, NULL, 0, timeout);
      if (err < 0) handle_usb_issue(err, __func__);
keep keep keep add keep keep keep keep
 boardd: return early from usb functions if not connected
selfdrive/boardd/panda.cc