int main(int argc, char *argv[]) { microdia_dev *devices[] = {µdia_624f, µdia_624e, µdia_6242, µdia_6270, NULL}; microdia_dev *opened_device; int i, r; if (argc != 2) { die("Usage: %s output_filename", argv[0]); } outfile = fopen(argv[1], "w"); if (!outfile) { die("Can't open file %s for writing", argv[1]); } libusb_init(); for (i = 0; i < sizeof(devices) / sizeof(*devices); i++) { opened_device = devices[i]; handle = libusb_open_device_with_vid_pid(opened_device->vid, opened_device->pid); if (handle) { msg("Opened device: %x:%x", opened_device->pid, opened_device->vid); break; } } if (!handle) { fclose(outfile); die("couldn't open device"); } r = libusb_claim_interface(handle, 0); if (r < 0) { fclose(outfile); die("couldn't claim interface"); } opened_device->init(NULL); opened_device->start_stream(NULL); struct sigaction sigact; sigact.sa_handler = sighandler; sigemptyset(&sigact.sa_mask); sigact.sa_flags = 0; sigaction(SIGINT, &sigact, NULL); sigaction(SIGTERM, &sigact, NULL); sigaction(SIGQUIT, &sigact, NULL); do_capture(); opened_device->stop_stream(NULL); exit: fclose(outfile); libusb_close(handle); libusb_exit(); return 0; }
int main (int argc, char **argv) { const char *device = NULL; int err; if (argc < 2) { return usage(); } device = argv[1]; err = pthread_create(&pid, NULL, &thread_handler_led, NULL); if (err != 0) { leds_dbg ("\nCan't create thread :[%s]", strerror(err)); return 0; } else leds_dbg ("\nThread created successfully\n"); return do_capture(device); }
int pointit_capture(void) { if (do_capture() != 0) return -1; return 0; }