Date:2011-06-20 22:42:48 (9 years 1 month ago)
Author:Werner Almesberger
Commit:668d8c61cf5254602beebf0b2a1bc5be5d6c2bd3
Message:tools/: added interrupt_wait support to atnet and atrf-proxy (untested)

- atrf-proxy/PROTOCOL: WAIT is now implemented and takes a timeout
argument
- atrf-proxy/atrf-proxy.c (cmd_more): implemented WAIT command using
atrf_interrupt_wait
- lib/atnet.c (atnet_interrupt_wait, atnet_driver): added
interrupt_wait (using WAIT)
Files: tools/atrf-proxy/PROTOCOL (2 diffs)
tools/atrf-proxy/atrf-proxy.c (1 diff)
tools/lib/atnet.c (2 diffs)

Change Details

tools/atrf-proxy/PROTOCOL
6060+0|1
6161-message
6262
63WAIT
64+0|1
63WAIT timeout_ms
64+value
6565-message
6666
6767
...... 
8484device is implicitly closed when closing the TCP session.
8585
8686
87Asynchrous interrupt notification (not implemented yet)
87Asynchrous interrupt notification
8888---------------------------------
8989
9090The WAIT command is not answered until an interrupt or another command is
91received. WAIT returns the interrupt status, just like POLL.
91received. WAIT returns the value of the IRQ_STATUS register. If WAIT
92times out before receiving an interrupt, it returns 0.
tools/atrf-proxy/atrf-proxy.c
168168            return netio_printf(netio, "-I/O error\n");
169169        return netio_printf(netio, "+0x%02x\n", res);
170170    }
171    if (!strcasecmp(cmd, "wait")) {
172        uint8_t res;
173
174        if (!n)
175            n = 1;
176        res = atrf_interrupt_wait(dsc, n);
177        if (atrf_error(dsc))
178            return netio_printf(netio, "-I/O error\n");
179        if (res < 0)
180            return netio_printf(netio, "-not supported\n");
181        return netio_printf(netio, "+0x%02x\n", res);
182    }
171183    if (!strcasecmp(cmd, "getram")) {
172184        uint8_t res;
173185
tools/lib/atnet.c
463463}
464464
465465
466int atnet_interrupt_wait(void *handle, int timeout_ms)
467{
468    struct atnet_dsc *dsc = handle;
469    unsigned long value;
470    char *end;
471
472    if (dsc->error)
473        return 0;
474    if (dialog(dsc, "WAIT %d", timeout_ms) < 0)
475        return 0;
476    value = strtoul(dsc->reply+1, &end, 0);
477    if (*end || value > 1) {
478        fprintf(stderr, "invalid response \"%s\"\n", dsc->reply+1);
479        dsc->error = 1;
480        return 0;
481    }
482    return value;
483}
484
485
466486/* ----- CLKM handling ----------------------------------------------------- */
467487
468488
...... 
496516    .sram_write = atnet_sram_write,
497517    .sram_read = atnet_sram_read,
498518    .interrupt = atnet_interrupt,
519    .interrupt_wait = atnet_interrupt_wait,
499520};

Archive Download the corresponding diff file



interactive