remsim: allow selecting pcsc reader number

The number can be queried using pcsc_scan -n

Change-Id: I9d347501a9f181f68e74799ad04a810553eb2c9e
diff --git a/host/src/simtrace2-remsim.c b/host/src/simtrace2-remsim.c
index 7d5ecd3..201ff71 100644
--- a/host/src/simtrace2-remsim.c
+++ b/host/src/simtrace2-remsim.c
@@ -182,6 +182,7 @@
 		"\t-i\t--gsmtap-ip\tA.B.C.D\n"
 		"\t-a\t--skip-atr\n"
 		"\t-k\t--keep-running\n"
+		"\t-n\t--pcsc-reader-num\n"
 		"\t-V\t--usb-vendor\tVENDOR_ID\n"
 		"\t-P\t--usb-product\tPRODUCT_ID\n"
 		"\t-C\t--usb-config\tCONFIG_ID\n"
@@ -200,6 +201,7 @@
 	{ "skip-atr", 0, 0, 'a' },
 	{ "help", 0, 0, 'h' },
 	{ "keep-running", 0, 0, 'k' },
+	{ "pcsc-reader-num", 1, 0, 'n' },
 	{ "usb-vendor", 1, 0, 'V' },
 	{ "usb-product", 1, 0, 'P' },
 	{ "usb-config", 1, 0, 'C' },
@@ -285,6 +287,7 @@
 	int remote_udp_port = 52342;
 	int if_num = 0, vendor_id = -1, product_id = -1;
 	int config_id = -1, altsetting = 0, addr = -1;
+	int reader_num = 0;
 	char *remote_udp_host = NULL;
 	char *path = NULL;
 	struct osim_reader_hdl *reader;
@@ -295,7 +298,7 @@
 	while (1) {
 		int option_index = 0;
 
-		c = getopt_long(argc, argv, "r:p:hi:V:P:C:I:S:A:H:ak", opts, &option_index);
+		c = getopt_long(argc, argv, "r:p:hi:V:P:C:I:S:A:H:akn:", opts, &option_index);
 		if (c == -1)
 			break;
 		switch (c) {
@@ -318,6 +321,9 @@
 		case 'k':
 			keep_running = 1;
 			break;
+		case 'n':
+			reader_num = atoi(optarg);
+			break;
 		case 'V':
 			vendor_id = strtol(optarg, NULL, 16);
 			break;
@@ -373,7 +379,7 @@
 		goto close_exit;
 	}
 
-	reader = osim_reader_open(OSIM_READER_DRV_PCSC, 0, "", NULL);
+	reader = osim_reader_open(OSIM_READER_DRV_PCSC, reader_num, "", NULL);
 	if (!reader) {
 		perror("unable to open PC/SC reader");
 		goto close_exit;