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.
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 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 @@
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);