embedded-trainings-2020/embedded-workshop-book/src/supporting-standard-requests.md
Jorge Aparicio 48e2ef512f rename USB parser solutions
also put them outside the `src` directory so people don't think they are modules
2020-07-14 13:28:23 +02:00

1.5 KiB

USB-4: Supporting more Standard Requests

After responding to the GET_DESCRIPTOR Device request the host will start sending different requests. The parser in common/usb will need to be updated to handle these requests:

  1. GET_DESCRIPTOR Configuration, see section Handling GET_DESCRIPTOR Configuration Requests
  2. SET_CONFIGURATION, see section SET_CONFIGURATION of this course material

The starter common/usb code contains unit tests for these other requests as well as extra Request variants for these requests. All of them have been commented out using a #[cfg(TODO)] attribute which you can remove once you need any new variant or new unit test.

For each green test, you can extend usb-4.rs to handle the new requests your parser is now able to recognize. Make sure to read the next sections as you're working, since they contain explanations about the concepts used and needed to complete this task.

If you need a reference, you can find solutions to parsing GET_DESCRIPTOR Configuration and SET_CONFIGURATION requests in the following files:

  • advanced/common/usb/solution-get-descriptor-configuration.rs
  • advanced/common/usb/solution-set-configuration.rs

Each file contains just enough code to parse the request in its name and the GET_DESCRIPTOR Device and SET_ADDRESS requests. So you can refer to solution-get-descriptor-configuration.rs without getting "spoiled" about how to parse the SET_CONFIGURATION request.