contrib: add AppStream metadata
[libam7xxx.git] / examples / am7xxx-modeswitch.c
index 1230bd4..c304515 100644 (file)
@@ -29,7 +29,7 @@
 
 static unsigned char switch_command[] =
        "\x55\x53\x42\x43\x08\x70\x52\x89\x00\x00\x00\x00\x00\x00"
 
 static unsigned char switch_command[] =
        "\x55\x53\x42\x43\x08\x70\x52\x89\x00\x00\x00\x00\x00\x00"
-       "\x0c\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
+       "\x10\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
 
 int main(void)
 {
 
 int main(void)
 {
@@ -71,7 +71,7 @@ int main(void)
                if (ret < 0) {
                        fprintf(stderr, "libusb_set_configuration failed: %s\n",
                                libusb_error_name(ret));
                if (ret < 0) {
                        fprintf(stderr, "libusb_set_configuration failed: %s\n",
                                libusb_error_name(ret));
-                       fprintf(stderr, "Cannot set configuration %hhu\n",
+                       fprintf(stderr, "Cannot set configuration %d\n",
                                AM7XXX_STORAGE_CONFIGURATION);
                        goto out_libusb_close;
                }
                                AM7XXX_STORAGE_CONFIGURATION);
                        goto out_libusb_close;
                }
@@ -83,12 +83,13 @@ int main(void)
        if (ret < 0) {
                fprintf(stderr, "libusb_claim_interface failed: %s\n",
                        libusb_error_name(ret));
        if (ret < 0) {
                fprintf(stderr, "libusb_claim_interface failed: %s\n",
                        libusb_error_name(ret));
-               fprintf(stderr, "Cannot claim interface %hhu\n",
+               fprintf(stderr, "Cannot claim interface %d\n",
                        AM7XXX_STORAGE_INTERFACE);
                goto out_libusb_close;
        }
 
                        AM7XXX_STORAGE_INTERFACE);
                goto out_libusb_close;
        }
 
-       /* Checking that the configuration has not changed, as suggested in
+       /*
+        * Checking that the configuration has not changed, as suggested in
         * http://libusb.sourceforge.net/api-1.0/caveats.html
         */
        current_configuration = -1;
         * http://libusb.sourceforge.net/api-1.0/caveats.html
         */
        current_configuration = -1;
@@ -100,13 +101,14 @@ int main(void)
        }
 
        if (current_configuration != AM7XXX_STORAGE_CONFIGURATION) {
        }
 
        if (current_configuration != AM7XXX_STORAGE_CONFIGURATION) {
-               fprintf(stderr, "libusb configuration changed (expected: %hhu, current: %hhu\n",
+               fprintf(stderr, "libusb configuration changed (expected: %d, current: %d)\n",
                        AM7XXX_STORAGE_CONFIGURATION, current_configuration);
                ret = -EINVAL;
                goto out_libusb_release_interface;
        }
 
        len = sizeof(switch_command);
                        AM7XXX_STORAGE_CONFIGURATION, current_configuration);
                ret = -EINVAL;
                goto out_libusb_release_interface;
        }
 
        len = sizeof(switch_command);
+
        transferred = 0;
        ret = libusb_bulk_transfer(usb_device, AM7XXX_STORAGE_OUT_EP,
                                   switch_command, len, &transferred, 0);
        transferred = 0;
        ret = libusb_bulk_transfer(usb_device, AM7XXX_STORAGE_OUT_EP,
                                   switch_command, len, &transferred, 0);