summaryrefslogtreecommitdiffstats
path: root/src/libftdi1-test.c
blob: 8252cf379ea2080773dc47bab2db6d4e4f59aa4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * This file is part of MXE.
 * See index.html for further information.
 */

#include <stdio.h>
#include <ftdi.h>

int main(int argc, char *argv[])
{
    int num_devs;
    struct ftdi_context *ctx;
    struct ftdi_device_list *devs = NULL;

    (void)argc;
    (void)argv;

    ctx = ftdi_new();
    if (!ctx) {
        printf("Initialization error.\n");
        return 1;
    }

    num_devs = ftdi_usb_find_all(ctx, &devs, 0, 0);
    if (num_devs < 0) {
        printf("Device list error: %s.\n", ftdi_get_error_string(ctx));
        ftdi_free(ctx);
        return 2;
    }

    printf("Found %d FTDI devices.\n", (int)num_devs);

    ftdi_list_free(&devs);

    ftdi_free(ctx);

    return 0;
}