#include #include #include #include #include "hid.h" void sendstr(char * tosend) { rawhid_send(0, tosend, strlen(tosend),1000); } #define NUM_DEVICE_IDS 3 uint16_t dev_ids[] = {0x0481, 0x0480, 0x0482}; int main (int argc, char *argv[]) { // C-based example is 16C0:0480:FFAB:0200 int r,d,w; for (d=0; d 0) break; } if (r <= 0) { printf("no rawhid device found, already in bootloader ?\n"); return 0; } sendstr("r"); // clear the buffer //now wait until device is gone for (w=0; w < 12; w++) { r = rawhid_open(1, 0x16C0, dev_ids[d], 0xFFAB, 0x0200); if (r > 0) { rawhid_close(r); sleep(1); } else { printf("device gone, reboot finished\n"); sleep(1); return 0; } } printf("device still there, reboot did not work ?\n"); return -1; }