  int Panda::usb_bulk_write(unsigned char endpoint, unsigned char* data, int length, unsigned int timeout) {
    int err;
    int transferred = 0;
  
    pthread_mutex_lock(&usb_lock);
    do {
      // Try sending can messages. If the receive buffer on the panda is full it will NAK
      // and libusb will try again. After 5ms, it will time out. We will drop the messages.
      err = libusb_bulk_transfer(dev_handle, endpoint, data, length, &transferred, timeout);
 
</s>
  if (!connected){
    return 0;
  }

  int Panda::usb_bulk_write(unsigned char endpoint, unsigned char* data, int length, unsigned int timeout) {
    int err;
    int transferred = 0;
  
  if (!connected){
    return 0;
  }

    pthread_mutex_lock(&usb_lock);
    do {
      // Try sending can messages. If the receive buffer on the panda is full it will NAK
      // and libusb will try again. After 5ms, it will time out. We will drop the messages.
      err = libusb_bulk_transfer(dev_handle, endpoint, data, length, &transferred, timeout);
keep keep keep add keep keep keep keep keep
 boardd: return early from usb functions if not connected
selfdrive/boardd/panda.cc