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.
This commit is contained in:
Harald Welte 2016-03-20 15:30:46 +01:00
parent cf1c19abe0
commit 1871c25b6d
1 changed files with 15 additions and 0 deletions

View File

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