X-Git-Url: https://git.ao2.it/visomat-utils.git/blobdiff_plain/49d57f3f34f76b24d5bba6adae90d04c8e8ed406..89ec9734ef0716e4b46cd33bc10434c677d860a6:/src/visomat-data-downloader.c diff --git a/src/visomat-data-downloader.c b/src/visomat-data-downloader.c index 69f62d6..574bb13 100644 --- a/src/visomat-data-downloader.c +++ b/src/visomat-data-downloader.c @@ -20,6 +20,7 @@ */ #include +#include #include #include #include @@ -322,12 +323,11 @@ static int visomat_dump_eeprom(visomat_device *dev, unsigned int user_mask) return ret; ret = get_response(dev, buffer, sizeof(buffer)); + debug("buffer size: %d\n", ret); + debug_dump_buffer("eeprom.bin", buffer, sizeof(buffer)); if (ret < 0) return ret; - debug("buffer len: %d\n", ret); - debug_dump_buffer("eeprom.bin", buffer, sizeof(buffer)); - ret = decode_eeprom(buffer, ret, user_mask); if (ret < 0) return ret; @@ -355,12 +355,38 @@ static int visomat_get_datetime(visomat_device *dev) return 0; } -int main(void) +static void usage(const char *name) +{ + printf("usage: %s [OPTIONS]\n\n", name); + printf("OPTIONS:\n"); + printf("\t-D\t\tenable libusb debug output\n"); + printf("\t-h\t\tthis help message\n"); +} + +int main(int argc, char *argv[]) { int ret; + int opt; + bool enable_libusb_debug = false; libusb_device_handle *dev; int current_configuration; + while ((opt = getopt(argc, argv, "Dh")) != -1) { + switch (opt) { + case 'D': + enable_libusb_debug = true; + break; + case 'h': + usage(argv[0]); + ret = 0; + goto out; + default: /* '?' */ + usage(argv[0]); + ret = -EINVAL; + goto out; + } + } + ret = libusb_init(NULL); if (ret < 0) { fprintf(stderr, "libusb_init failed: %s\n", @@ -368,7 +394,8 @@ int main(void) goto out; } - libusb_set_debug(NULL, LIBUSB_LOG_LEVEL_INFO); + libusb_set_debug(NULL, enable_libusb_debug ? + LIBUSB_LOG_LEVEL_DEBUG : LIBUSB_LOG_LEVEL_INFO); dev = libusb_open_device_with_vid_pid(NULL, VISOMAT_DEVICE_VID,