X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=ao-tools%2Fao-chaosread%2Fao-chaosread.c;h=b0a6168aa71e991fc7f7e7ee86f55d299c4d2074;hp=8a814a009ed7b20b405877431a334d6918c03a73;hb=31f9ed231e63b214b405a141cabce3eb758e82e6;hpb=db7f7c6c7f956058250b8057c6c27284f6f22e53 diff --git a/ao-tools/ao-chaosread/ao-chaosread.c b/ao-tools/ao-chaosread/ao-chaosread.c index 8a814a00..b0a6168a 100644 --- a/ao-tools/ao-chaosread/ao-chaosread.c +++ b/ao-tools/ao-chaosread/ao-chaosread.c @@ -36,7 +36,7 @@ struct chaoskey { int kernel_active; }; -libusb_device_handle * +static libusb_device_handle * chaoskey_match(libusb_device *dev, char *match_serial) { struct libusb_device_descriptor desc; @@ -96,7 +96,7 @@ out: return 0; } -struct chaoskey * +static struct chaoskey * chaoskey_open(char *serial) { struct chaoskey *ck; @@ -161,21 +161,11 @@ out: return NULL; } -void -chaoskey_close(struct chaoskey *ck) -{ - libusb_release_interface(ck->handle, 0); - if (ck->kernel_active) - libusb_attach_kernel_driver(ck->handle, 0); - libusb_close(ck->handle); - libusb_exit(ck->ctx); - free(ck); -} - #define COOKED_ENDPOINT 0x85 #define RAW_ENDPOINT 0x86 +#define FLASH_ENDPOINT 0x87 -int +static int chaoskey_read(struct chaoskey *ck, int endpoint, void *buffer, int len) { uint8_t *buf = buffer; @@ -208,12 +198,13 @@ static const struct option options[] = { { .name = "bytes", .has_arg = 0, .val = 'b' }, { .name = "cooked", .has_arg = 0, .val = 'c' }, { .name = "raw", .has_arg = 0, .val = 'r' }, + { .name = "flash", .has_arg = 0, .val = 'f' }, { 0, 0, 0, 0}, }; static void usage(char *program) { - fprintf(stderr, "usage: %s [--serial=] [--length=[kMG]] [--infinite] [--bytes] [--cooked] [--raw]\n", program); + fprintf(stderr, "usage: %s [--serial=] [--length=[kMG]] [--infinite] [--bytes] [--cooked] [--raw] [--flash]\n", program); exit(1); } @@ -233,7 +224,7 @@ main (int argc, char **argv) int bytes = 0; int endpoint = RAW_ENDPOINT; - while ((c = getopt_long(argc, argv, "s:l:ibcr", options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "s:l:ibcrf", options, NULL)) != -1) { switch (c) { case 's': serial = optarg; @@ -262,6 +253,9 @@ main (int argc, char **argv) case 'r': endpoint = RAW_ENDPOINT; break; + case 'f': + endpoint = FLASH_ENDPOINT; + break; default: usage(argv[0]); break;