EspoTek / Labrador

EspoTek Labrador is a USB device that transforms your PC or smartphone into a fully-featured electronics lab. This repo holds all of the source code!
http://espotek.com
1.1k stars 116 forks source link

Extending Labrador vendor requests #260

Closed mmehari closed 5 months ago

mmehari commented 5 months ago

Hello again,

This time I am planning to add a new feature which requires a new vendor request but while experimenting to add one, I ended up having the following error message

unixUsbDriver::usbSendControl FAILED with error LIBUSB_ERROR_PIPE

What I did to recreate the error message was updated SIGNAL GEN CH1 command from 0xa1 to 0xb1 in the following two files

  1. https://github.com/EspoTek/Labrador/blob/master/AVR_Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.c#L1108
  2. https://github.com/EspoTek/Labrador/blob/master/Desktop_Interface/genericusbdriver.cpp#L235

Would you please let me know what I am missing?

EspoTek commented 5 months ago

Hi again, Michael!

At least in theory, that should have done the trick!

In practice, though, there's a feature that automatically flashes the "correct" firmware to the board that could be interfering with your code. To rule this out, it'd be best practice to increment the EXPECTED_FIRMWARE_VERSION in the desktop app, and the FIRMWARE_VERSION_ID in globals.h on the microcontroller side.

If you're running on any operating system that isn't Windows x64, you'll also want to uncomment the line defining SINGLE_ENDPOINT_INTERFACE (also in globals.h). This changes the headers so that it uses 1x 1023-byte isochronous endpoint, rather than 6x 128-byte endpoints to send the scope/logic analyzer data. On non-Windows-x64, the ordering of the transfers isn't deterministic, so using 6x endpoints leads to a corrupt signal on the oscilloscope/logic analyzer.

The other thing I'll mention in general is that Wireshark is an excellent tool for capturing raw(ish) USB packet data. You can see exactly what data is sent to the device, and exactly what the response is. Just make sure you check the "install USBPcap" box when installing it if you're on Windows (don't install USBPcap separately - it doesn't work properly).

mmehari commented 5 months ago

Indeed you were right.

My firmware was overwritten by the default firmware and increasing the FIRMWARE_VERSION_ID solves the issue.

And yes I am already using Wireshark to debug the low level USB traffic and indeed it is very helpful.

Now I will focus on the new feature I am trying to bring and hopefully, I will see you in a new pull request

EspoTek commented 5 months ago

Great news! Can't wait to see the PR! I'll mark this issue as closed now.