1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2025-04-21 12:27:27 +03:00

atspi-txrx can now send repeatedly, cleans up on ^C, prints the power level.

if it differs by more than 0.01 dBm from the level specified
- tools/atspi-txrx/Makefile (LDLIBS): added -lm, for fabs()
- tools/atspi-txrx/atspi-txrx.c (transmit, usage, main): add optional
  command-line argument with the number of times to send the message
- tools/atspi-txrx/atspi-txrx.c (receive, transmit, die, main): return and
  clean up on ^C
- tools/tools/lib/misctxrx.c (wait_for_interrupt) return and raise SIGINT
  for the caller's signal handler on ^C
This commit is contained in:
Werner Almesberger
2010-09-14 17:12:03 -03:00
parent b390b28364
commit c99ba2c769
3 changed files with 54 additions and 12 deletions

View File

@@ -15,19 +15,32 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include "at86rf230.h"
#include "atspi.h"
#include "misctxrx.h"
static volatile int run = 1;
static void die(int sig)
{
run = 0;
}
uint8_t wait_for_interrupt(struct atspi_dsc *dsc, uint8_t wait_for,
uint8_t ignore, int sleep_us, int timeout)
{
uint8_t irq, show;
uint8_t irq = 0, show;
void (*old_sig)(int);
while (1) {
while (!atspi_interrupt(dsc)) {
run = 1;
old_sig = signal(SIGINT, die);
while (run) {
while (run && !atspi_interrupt(dsc)) {
usleep(sleep_us);
if (timeout && !--timeout)
return 0;
@@ -57,5 +70,8 @@ uint8_t wait_for_interrupt(struct atspi_dsc *dsc, uint8_t wait_for,
if (irq & wait_for)
break;
}
signal(SIGINT, old_sig);
if (!run)
raise(SIGINT);
return irq;
}