-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when WriteContext is called #92
Comments
What platform is this on? Can you downgrade libusb to the previous version and compare? The actual version numbers would be useful. Also a small code that reproduces the issue would be helpful. |
@zagrodzki some code at this point I already opened the device session and have a handler to it and to the interface. var abletonVendorID gousb.ID = 0x2982
var pushProductID gousb.ID = 0x1967
var frameHeader = []byte{0xff, 0xcc, 0xaa, 0x88,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00}
var (
debug = flag.Int("debug", 0, "libusb debug level (0..3)")
)
type AbletonPush2DisplayInterface interface {
Open() error
Close() error
}
// Display - Ableton Push 2 Display Interface
type AbletonPush2Display struct {
pixels []byte
device *gousb.Device
ctx *gousb.Context
intf *gousb.Interface
}
func (display *AbletonPush2Display) WritePixels(pixels []uint8) error {
outEp, _ := display.intf.OutEndpoint(1)
ctx := context.Background()
_, err := outEp.WriteContext(ctx, frameHeader)
_, err := outEp.WriteContext(ctx, pixels)
return err
} |
@zagrodzki unrelated to this project but the error output is pretty similar to what I have here |
@zagrodzki I was able to validate that the issue is due to libusb-1.0.24 being installed on my machine. |
I'm not sure yet what changes in 1.0.24 triggered this. In the meantime, please fix your code to not ignore the error from the OutEndpoint() as well as from the first WriteContext(). I'd like to see also the rest of the initialization code, i.e. how you obtain the USB context, open the config and claim the interface. |
Also please attach the full output, there's more data in there. |
@zagrodzki thanks for the feedback. I pretty much went by an example I saw somewhere here on the repo to open device and claim the interface - it's been a while... But please have a look as I am sure I am doing something really dumb. To be honest when doing this in c++ or wrapping libusb to use in swift I was successful as the api was pretty much what's on libusb docs. On this package some things feel slightly different and maybe this is because I haven't read enough of the docs - which I am currently going through again slowly. Here is the repo with the code - although without the hardware it would fail running: |
Here is the full console output as well
|
I believe this is a bug in your code: you close the context before returning from We should probably add better error messages for this case. |
Omg this is so obvious 🤦🏾♂️! I never paid attention to that as it's pretty much a copy pasta from the docs. Yes that was the issue here. Thanks! |
Hi,
I was using gousb successfully until today. I honestly don't know what happened but now every time I try to run the same code that calls
outEp.WriteContext(ctx, buffer)
I getI have code that hasn't been touched in weeks that is now failing but I don't know the reason. I may have upgraded libusb.
The text was updated successfully, but these errors were encountered: