Skip to content

Latest commit

 

History

History

examples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Raw Gadget Examples

This directory contains two examples of using Raw Gadget:

  • keyboard.c emulates a USB keyboard that keeps sending keypresses of the letter x. This example also handles the USB device being reset by the host;

  • printer.c emulates the enumeration stage of a USB printer.

When run without arguments, the examples rely on the Dummy HCD/UDC module to emulate virtual devices that connect to the kernel they are running on. If you want to use them with a physical host instead, you need to provide the UDC device and driver names as arguments (e.g. both are 20980000.usb for Raspberry Pi Zero).

Also see tests/gadget.c for an example of a device that is used with the Raw Gadget testing suite.

Usage

Build:

make

For keyboard

Run:

sudo ./keyboard

Or:

sudo ./keyboard 20980000.usb 20980000.usb

For printer

Run:

sudo ./printer

Or:

sudo ./printer 20980000.usb 20980000.usb