/* ----------------------------------------------------------------------------1* "THE BEER-WARE LICENSE" (Revision 42) (by Poul-Henning Kamp):2* <[email protected]> wrote this file. As long as you retain this notice you3* can do whatever you want with this stuff. If we meet some day, and you think4* this stuff is worth it, you can buy me a beer in return. Joerg Wunsch5* ----------------------------------------------------------------------------6*/78/*9* Helper functions common to all examples10*/1112#include <stdio.h>13#include <stdint.h>14#include <stdlib.h>1516#include <libusb20.h>17#include <libusb20_desc.h>1819#include "util.h"2021/*22* Print "len" bytes from "buf" in hex, followed by an ASCII23* representation (somewhat resembling the output of hd(1)).24*/25void26print_formatted(uint8_t *buf, uint32_t len)27{28int i, j;2930for (j = 0; j < len; j += 16)31{32printf("%02x: ", j);3334for (i = 0; i < 16 && i + j < len; i++)35printf("%02x ", buf[i + j]);36printf(" ");37for (i = 0; i < 16 && i + j < len; i++)38{39uint8_t c = buf[i + j];40if(c >= ' ' && c <= '~')41printf("%c", (char)c);42else43putchar('.');44}45putchar('\n');46}47}484950