Skip to content
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

USBTMC: Fixes and support for high-speed USB #1531

Merged
merged 6 commits into from
Jul 18, 2022

Conversation

pigrew
Copy link
Collaborator

@pigrew pigrew commented Jun 25, 2022

This updates USBTMC so that it should work with USB high-speed (untested, I don't have a HS device handy...).

It also fixes a few existing bugs:

  1. Updates python test code to use newer versions of pyvisa
  2. Manually stalls and unstalls an endpoint when receiving clear_feature(ENDPOINT_HALT), fixes USBTMC triggers assertion soon after configuration, due to extra CLEAR_FEATURE(ENDPT_HALT) #1529
  3. Reads the max packet size from the endpoint descriptors, instead of using a compile-time define.

The fix for the endpoint halt clearing likely should be put in the USBD core itself, instead of the class driver, but that's up for discussion. The USB488 spec mentions that the class may want to prevent the HALT from being cleared... I'd be happy for this patch to be merged, and then I can propose a larger fix.

@pigrew pigrew requested a review from hathach June 25, 2022 03:20
@pigrew
Copy link
Collaborator Author

pigrew commented Jun 26, 2022

Thinking more, it would be good to have a way to clear the event queue of transfers on the particular endpoint during the clear_feature call, but we can leave that for another day. This patch is a step in the proper direction.

@hathach
Copy link
Owner

hathach commented Jun 28, 2022

sorry for late response, I will pull out one of my board with HS to test with as soon as I could :) .

@pigrew
Copy link
Collaborator Author

pigrew commented Jun 28, 2022

Great. Let me know if you have any questions.

Do you use Windows? If not, I believe that Linux comes with a kernel driver for USBTMC, which will operate with python's pyvisa library. On Windows, the driver I mentioned comes with the "NI MAX" software that allows manual interaction with the device. In the tinyusb USBTMC example, I do have a python script that runs a number of testcases using pyvisa (which is how I found this bug, though it is intermittent).

I'm also contemplating creating testcases for the CLEAR_FEATURE bug. I don't think that's possible with the standard USBTMC drivers, so it would need to use something like libusb, which makes it less convenient to run on Windows.

@pigrew
Copy link
Collaborator Author

pigrew commented Jul 9, 2022

I updated this branch to fix #1532.

@pigrew pigrew linked an issue Jul 9, 2022 that may be closed by this pull request
Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superb! Thank you very much for your PR, and sorry for late response. I have got into too many issues lately :)

@hathach hathach merged commit 2110e27 into hathach:master Jul 18, 2022
@pigrew
Copy link
Collaborator Author

pigrew commented Jul 18, 2022

Were you able to do testing with HS USB to confirm it works?

@hathach
Copy link
Owner

hathach commented Jul 18, 2022

Were you able to do testing with HS USB to confirm it works?

I would love to, but not yet. The changes look great, but you are right, it may not be enough. I will try to pull out my old windows laptop and get it set up to test with. Will post the testing result here as soon as I could.

@pigrew
Copy link
Collaborator Author

pigrew commented Jul 18, 2022

While I've been using Windows... Linux does have USBTMC support, though I don't know if it'd run into the same ENDPOINT_HALT bug or not.

@hathach
Copy link
Owner

hathach commented Jul 18, 2022

Thanks for the reminder, to be honest, I haven't tried usbtmc before, I will give it a try this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants