Root/atrf/tools/atspi-reset/atspi-reset.c

Source at commit c2dd23840ce5875deca09673fcb8abb8dc3a8e7a created 9 years 1 month ago.
By Werner Almesberger, Moved fw/ and tools/ into atrf/ as well.
1/*
2 * atspi-rssi/atspi-rssi.c - ben-wpan AF86RF230 spectrum scan
3 *
4 * Written 2010 by Werner Almesberger
5 * Copyright 2010 Werner Almesberger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13
14#include <stdlib.h>
15#include <stdio.h>
16#include <string.h>
17#include <usb.h>
18
19#include "atspi.h"
20
21
22static void usage(const char *name)
23{
24    fprintf(stderr,
25"usage: %s [-a|-t]\n\n"
26" -a reset the MCU and transceiver\n"
27" -t reset transceiver (default)\n"
28    , name);
29    exit(1);
30}
31
32
33int main(int argc, const char **argv)
34{
35    usb_dev_handle *dev;
36    int txrx = 1;
37
38    switch (argc) {
39    case 1:
40        break;
41    case 2:
42        if (!strcmp(argv[1], "-t"))
43            break;
44        txrx = 0;
45        if (!strcmp(argv[1], "-a"))
46            break;
47        /* fall through */
48    default:
49        usage(*argv);
50    }
51
52    dev = atspi_open();
53    if (!dev)
54        return 1;
55
56        if (txrx)
57                atspi_reset_rf(dev);
58        else
59                atspi_reset(dev);
60        return 0;
61}
62
63

Archive Download this file



interactive