Monday, 12 March 2007

Fujifilm remote capture stream.c diff

[See also, Time Lapse Photography, Part 1]

stream.c
--- stream.c    2007-03-11 18:00:53.000000000 +0000
+++ stream.c.new        2007-03-11 18:01:22.000000000 +0000
@@ -30,7 +30,8 @@
        for (dev = bus->devices; dev; dev = dev->next) {
            if (dev->descriptor.idVendor == 0x04cb) {
                // OK, it's a FUJI
-               if (dev->descriptor.idProduct == 0x0125) {
+               if (dev->descriptor.idProduct == 0x0125
+                   || dev->descriptor.idProduct == 0x010b) {
                    printf("Found it on bus %d(%s), dev %s.n",
                           bus->location, bus->dirname, dev->filename);
                    // our product
@@ -50,8 +51,14 @@
 #define BULK_WRITE_ENDPOINT   0x02
 #define INTR_ENDPOINT         0x03

+#define        DEBUG_OUTPUT                    0
+
+#if DEBUG_OUTPUT
 #define DEBUG(txt, ...) 
   fprintf(stderr, "DEBUG[%s:%d]: " txt "n", __FUNCTION__, __LINE__, ##__VA_ARGS__);
+#else
+#define DEBUG(txt, ...) fprintf(stderr,"");
+#endif

 #define VERIFY(code) 
   code; 
@@ -242,8 +249,6 @@
        DEBUG("Frame [2]");
        len = usb_bulk_read(udev, BULK_READ_ENDPOINT, buf, 0x2000, 3000);
        if (len < 0) {
-           fprintf(stderr, "Failed to get bulk frame datan");
-           return frame;
            frame_free(frame);
            return NULL;
        }
@@ -260,6 +265,7 @@
     int res;
     int i;
     struct usb_interface_descriptor *intf;
+    struct frame *frame;

     usb_init();
     usb_find_busses();
@@ -267,7 +273,7 @@

     dev = find_our_black_sheep();
     if (!dev) {
-       fprintf(stderr, "No FUJI FinePix A310 found.n");
+       fprintf(stderr, "No FUJI FinePix found.n");
        goto end;
     }

@@ -311,19 +317,19 @@
        if (argc > 1)
            count = atol(argv[1]);

-       for (i = 0; count-- > 0; ++i) {
+       for (i = 0; i < count; i++) {
            char filename[32];
-           struct frame *frame = get_frame();
-           if (!frame) {
-               fprintf(stderr, "Can't get framen");
-               break;
-           }
+           frame = get_frame();
+           if (frame) {
                sprintf(filename, "out/frame%05d.jpg", i);
                FILE *f = fopen(filename, "wb");
                fwrite(frame->data, frame->length, 1, f);
-               frame_free(frame);
                fflush(f);
                fclose(f);
+           } else {
+               fprintf(stderr,
+                       "Problem with frame %05d.  Trying again.n", i--);
+           }
        }
     }

No comments:

Post a Comment