1 /* ----------------------------------------------------------------------------
2 * "THE BEER-WARE LICENSE" (Revision 42) (by Poul-Henning Kamp):
3 * <joerg@FreeBSD.ORG> wrote this file. As long as you retain this notice you
4 * can do whatever you want with this stuff. If we meet some day, and you think
5 * this stuff is worth it, you can buy me a beer in return. Joerg Wunsch
6 * ----------------------------------------------------------------------------
12 * Helper functions common to all examples
20 #include <libusb20_desc.h>
25 * Print "len" bytes from "buf" in hex, followed by an ASCII
26 * representation (somewhat resembling the output of hd(1)).
29 print_formatted(uint8_t *buf, uint32_t len)
33 for (j = 0; j < len; j += 16)
37 for (i = 0; i < 16 && i + j < len; i++)
38 printf("%02x ", buf[i + j]);
40 for (i = 0; i < 16 && i + j < len; i++)
42 uint8_t c = buf[i + j];
43 if(c >= ' ' && c <= '~')
44 printf("%c", (char)c);