google / gousb

gousb provides low-level interface for accessing USB devices
Apache License 2.0
845 stars 124 forks source link

A lot of interrupted errors on MacOSX: handle_events: error: libusb: interrupted [code -10] #87

Closed ghost closed 8 months ago

ghost commented 4 years ago

Recently I have seen a lot of these errors: handle_events: error: libusb: interrupted [code -10] on Mac OS X and Linux with the latest LibUsb

libusb: stable 1.0.23 (bottled), HEAD
Library for USB device access
https://libusb.info/
/usr/local/Cellar/libusb/1.0.23 (26 files, 474.2KB) *

This actually just seems to be a return code from libusb handle_events_with_timeout, that does not really indicate an error but just that the eventhandler was interrupted. Maybe this should be a debug log? Right now it seems like something is broken, while actually everything works as expected.

malc0mn commented 2 years ago

Just to second this, using libusb 1.0.24-2 on Manjaro linux and gousb v1.1.1

zoracape commented 2 years ago

Thanks for reporting it. I encountered this issue on Linux and I don't seem to find any problem with USB communication. It is probably just a debug log.

Also thanks malc0mn for the suggestion. I just updated libusb.go and disabled this log.

FIS-X commented 2 years ago

Is there a way to remove this error?

danielpaulus commented 2 years ago

I am using this stdlog.SetOutput(new(LogrusWriter)) where stdlog is the regular golang logger import stdlog "log" and

type LogrusWriter int

const interruptedError = "interrupted [code -10]"

func (LogrusWriter) Write(data []byte) (int, error) {
    logmessage := string(data)
    if strings.Contains(logmessage, interruptedError) {
        log.Tracef("gousb_logs:%s", logmessage)
        return len(data), nil
    }
    log.Infof("gousb_logs:%s", logmessage)
    return len(data), nil
}

it is a workaround for Logrus, but you can probably adapt it to whatever you are using.

FIS-X commented 2 years ago

I am using this stdlog.SetOutput(new(LogrusWriter)) where stdlog is the regular golang logger import stdlog "log" and

type LogrusWriter int

const interruptedError = "interrupted [code -10]"

func (LogrusWriter) Write(data []byte) (int, error) {
  logmessage := string(data)
  if strings.Contains(logmessage, interruptedError) {
      log.Tracef("gousb_logs:%s", logmessage)
      return len(data), nil
  }
  log.Infof("gousb_logs:%s", logmessage)
  return len(data), nil
}

it is a workaround for Logrus, but you can probably adapt it to whatever you are using.

Thank you!

djadala commented 1 year ago

Same here in linux: github.com/google/gousb/libusb.go:191: handle_events: error: libusb: interrupted [code -10]

x-abgth commented 1 year ago

I'm also getting the same error log while erasing the device, and the erasing process is very slow in golang compared to python code. I think the slowness of the erase process is because of the same error.

PS: I converted the python code to golang code manually.

akares commented 11 months ago

Same here in macOS 14.1.1:

2023/12/04 00:58:46 handle_events: error: libusb: interrupted [code -10]

It seems working properly, just annoying messages.

Related gousb code: https://github.com/google/gousb/blob/844d4b8a718f46eb580a7a84afa00eb15c1b7a9a/libusb.go#L182-L194