Date:2013-06-23 07:03:26 (6 years 5 months ago)
Author:Werner Almesberger
Commit:172208e4511f1a6ad9b80229871329554fd4995a
Message:tools/atrf-txrx/atrf-txrx.c: use -x also on reception, to output message in hex

Files: tools/atrf-txrx/atrf-txrx.c (6 diffs)

Change Details

tools/atrf-txrx/atrf-txrx.c
146146/* ----- Message transmit/receive ------------------------------------------ */
147147
148148
149static void receive_message(struct atrf_dsc *dsc)
149static void receive_message(struct atrf_dsc *dsc, int hex)
150150{
151151    uint8_t buf[MAX_PSDU+1]; /* PSDU+LQI */
152152    int n, ok, i;
...... 
170170    lqi = buf[n-1];
171171    fprintf(stderr, "%d bytes payload, CRC %s, LQI %u, ED %d dBm\n",
172172        n-3, ok ? "OK" : "BAD", lqi, -91+ed);
173    for (i = 0; i != n-3; i++)
174        putchar(buf[i] < ' ' || buf[i] > '~' ? '?' : buf[i]);
173    if (hex) {
174        for (i = 0; i != n-3; i++)
175            printf("%s%02x", i ? " " : "", buf[i]);
176    } else {
177        for (i = 0; i != n-3; i++)
178            putchar(buf[i] < ' ' || buf[i] > '~' ? '?' : buf[i]);
179    }
175180    putchar('\n');
176181}
177182
...... 
256261}
257262
258263
259static void receive(struct atrf_dsc *dsc, const char *name)
264static void receive(struct atrf_dsc *dsc, const char *name, int hex)
260265{
261266    atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_RX_ON);
262267    /*
...... 
268273    if (name)
269274        receive_pcap(dsc, name);
270275    else
271        receive_message(dsc);
276        receive_message(dsc, hex);
272277}
273278
274279
...... 
631636static void usage(const char *name)
632637{
633638    fprintf(stderr,
634"usage: %s [common_options] [[-x] message [repetitions]]\n"
639"usage: %s [common_options] [-x] [message [repetitions]]\n"
635640" %s [common_options] -H [message]\n"
636641" %s [common_options] -E pause_s [repetitions]\n"
637642" %s [common_options] -P [max_wait_s]\n"
...... 
811816        set_rate(dsc, rate);
812817        switch (mode) {
813818        case mode_msg:
814            receive(dsc, pcap_file);
819            receive(dsc, pcap_file, hex);
815820            break;
816821        case mode_hmac:
817822            receive_hmac(dsc);

Archive Download the corresponding diff file



interactive