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

stmhal: implement HID OUT endpoint (USB receive) #2448

Closed
wants to merge 6 commits into from

Conversation

prusnak
Copy link
Contributor

@prusnak prusnak commented Sep 22, 2016

This changeset implements HID OUT endpoint, which allows receiving data on the uPy side of things.

Original commits from https://github.com/philandstuff/micropython/tree/usb-hid-out-endpoint, added few more fixes by me.

@prusnak
Copy link
Contributor Author

prusnak commented Sep 22, 2016

Implements #1217

@prusnak
Copy link
Contributor Author

prusnak commented Sep 22, 2016

To test:

  • Put this into boot.py:
import pyb
pyb.usb_mode('VCP+HID')
  • Run this in uPy REPL:
import pyb
h = pyb.USB_HID()
h.recv(4)
  • On PC side do the following:
import hid
h = hid.device()
h.open(0xf055, 0x9801)
h.write([0] + range(4))

recv function should return bytes.

(Also works with packet size of 64, but one needs to specify custom hid descriptor in pyb.usb_mode() function using its hid argument).

}

// Copy bytes from device to user buffer
memcpy(buf, buffer[current_read_buffer], last_read_len);
Copy link
Member

Choose a reason for hiding this comment

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

The len argument to this function is not used at all, in particular this line could overrun buf if buf is too short.

@@ -0,0 +1,36 @@
/*
Copy link
Member

Choose a reason for hiding this comment

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

This is such a simple file. The original copyright is not needed.

}

Copy link
Member

Choose a reason for hiding this comment

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

Please keep this blank line.

@@ -0,0 +1,109 @@
/*
* TODO: this header is even more lies now
Copy link
Member

Choose a reason for hiding this comment

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

Where did the bulk of this file come from, an ST example?

@prusnak
Copy link
Contributor Author

prusnak commented Sep 27, 2016

Pushed a new commit fixing the issues.

@dpgeorge
Copy link
Member

dpgeorge commented Oct 4, 2016

I tested it and there was a bug: needed to adjust size of MAX_TEMPLATE_CONFIG_DESC_SIZE from 100 to 107.

Otherwise it works well. Thanks for the submission, it's a very cool feature to have!

During the merge I squashed some commits in various ways to try and make the history a bit cleaner. See 99d62c4 for last of the 4 commits.

@dpgeorge dpgeorge closed this Oct 4, 2016
@prusnak
Copy link
Contributor Author

prusnak commented Oct 4, 2016

Thanks!

@prusnak prusnak deleted the hid_recv branch October 4, 2016 08:16
tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Jan 9, 2020
Add PacketBuffer and MTU negotiation support.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants