Created
May 11, 2016 13:22
-
-
Save pcercuei/6c87d464d4dc950bd8140c72fd6cc2b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iio.h> | |
#include <stdbool.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
static void scan_cb(const char *uri, const char *description, | |
bool connected, void *user_data) | |
{ | |
bool *found = user_data; | |
printf("Device %s with URI %s %sconnected!\n", | |
description, uri, connected ? "" : "dis"); | |
*found = true; | |
} | |
int main(void) | |
{ | |
struct iio_scan_context *scan; | |
bool found = false; | |
scan = iio_create_scan_context(scan_cb, &found); | |
if (!scan) { | |
perror("Unable to create scan context"); | |
return EXIT_FAILURE; | |
} | |
printf("Scan context created, polling now\n"); | |
do { | |
if (!iio_scan_context_poll(scan)) | |
usleep(4000); | |
} while (!found); | |
iio_scan_context_destroy(scan); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment