Example #1
0
int main(int argc, char **argv)
{
    char *devname;
    int iflag = 0, nflag = 0, cflag = 0, tflag = 0;

    progname = *argv;
    for (;;) {
        switch (getopt(argc, argv, "vdinct:")) {
        case EOF:
            break;
        case 'v':
            verbose++;
            continue;
        case 'd':
            dyio_debug++;
            continue;
        case 'i':
            iflag++;
            continue;
        case 'n':
            nflag++;
            continue;
        case 'c':
            cflag++;
            continue;
        case 't':
            tflag = strtol(optarg, 0, 0);
            continue;
            usage();
        }
        break;
    }
    argc -= optind;
    argv += optind;
    if (! iflag && ! nflag && ! cflag && !tflag) {
        /* By default, print generic information. */
        iflag++;
        verbose++;
    }

    if (argc != 1)
        usage();
    devname = argv[0];

    if (verbose)
        printf("Port name: %s\n", devname);

    dyio_connect(devname);

    if (iflag)
        dyio_info();
    if (nflag)
        dyio_print_namespaces();
    if (cflag)
        dyio_print_channels();
    switch (tflag) {
    case 1:
        test1();
    }
    return 0;
}
Example #2
0
int main(int argc, char **argv)
{
    char *devname;
    int iflag = 0, nflag = 0, cflag = 0, tflag = 0;
    int debug = 0;
    dyio_t *d;

    progname = *argv;
    for (;;) {
        switch (getopt(argc, argv, "vdinct:")) {
        case EOF:
            break;
        case 'v':
            verbose++;
            continue;
        case 'd':
            debug++;
            continue;
        case 'i':
            iflag++;
            continue;
        case 'n':
            nflag++;
            continue;
        case 'c':
            cflag++;
            continue;
        case 't':
            tflag = strtol(optarg, 0, 0);
            continue;
            usage();
        }
        break;
    }
    argc -= optind;
    argv += optind;
    if (! iflag && ! nflag && ! cflag && !tflag) {
        /* By default, print generic information. */
        iflag++;
        verbose++;
    }

    if (argc != 1)
        usage();
    devname = argv[0];

    if (verbose)
        printf("Port name: %s\n", devname);

    d = dyio_connect(devname, debug);
    if (! d) {
        printf("Failed to open port %s\n", devname);
        exit(-1);
    }

    if (verbose)
        printf("DyIO device address: %02x-%02x-%02x-%02x-%02x-%02x\n",
            d->reply_mac[0], d->reply_mac[1], d->reply_mac[2],
            d->reply_mac[3], d->reply_mac[4], d->reply_mac[5]);

    if (iflag)
        dyio_info(d);

    if (nflag)
        dyio_print_namespaces(d);

    if (cflag) {
        if (verbose)
            dyio_print_channel_features(d);
        dyio_print_channels(d);
    }

    switch (tflag) {
    case 1:
        test1(d);
        break;

    /* TODO: add more tests here.
    case 2:
        test1(d);
        break;
    */
    }

    dyio_close(d);
    return 0;
}