aboutsummaryrefslogtreecommitdiffstats
path: root/host/simtrace2-remsim.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-03-20 15:30:46 +0100
committerHarald Welte <laforge@gnumonks.org>2016-03-20 15:30:46 +0100
commit1871c25b6d0a924733dc15cfdc3fd8434eb20b61 (patch)
tree31fbf9b27f2ae0887b1f6dee0af3e06b24eb324e /host/simtrace2-remsim.c
parentcf1c19abe04d876c3020bfc65b8eeef5cf895d0a (diff)
simtrace2-remsim: Instruct SAM3S to simulate card removal on SIGINT
When stopping the program, we inform the card simulator to indicate a card removal to the GSM phone/modem.
Diffstat (limited to 'host/simtrace2-remsim.c')
-rw-r--r--host/simtrace2-remsim.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/host/simtrace2-remsim.c b/host/simtrace2-remsim.c
index b96d481..173ef2c 100644
--- a/host/simtrace2-remsim.c
+++ b/host/simtrace2-remsim.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
+#include <signal.h>
#include <time.h>
#define _GNU_SOURCE
#include <getopt.h>
@@ -384,6 +385,18 @@ static void run_mainloop(void)
}
}
+static void signal_handler(int signal)
+{
+ switch (signal) {
+ case SIGINT:
+ request_card_insert(false);
+ exit(0);
+ break;
+ default:
+ break;
+ }
+}
+
int main(int argc, char **argv)
{
char *gsmtap_host = "127.0.0.1";
@@ -473,6 +486,8 @@ int main(int argc, char **argv)
goto close_exit;
}
+ signal(SIGINT, &signal_handler);
+
do {
if (g_udp_fd < 0) {
g_devh = libusb_open_device_with_vid_pid(NULL, SIMTRACE_USB_VENDOR, SIMTRACE_USB_PRODUCT);