lynxis lazus has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/36983?usp=email )


Change subject: remsim_client: add support to set sim presence pin polarity
......................................................................

remsim_client: add support to set sim presence pin polarity

The sim presence pin allows the simtrace2 to inform the modem
about the presence of the simcard. On a generic simcard slot a
button is pressed by the simcard which generate a high or low voltage level.
Even there are specifications of minipcie or ngff defining this signal, certain
modems don't follow the specification and require a different signal level.

Change-Id: Iaa61967d2e8cd5c2269b73f4e65b42072e0ec513
---
M TODO-RELEASE
M configure.ac
M src/client/Makefile.am
M src/client/client.h
M src/client/remsim_client_main.c
M src/client/user_simtrace2.c
6 files changed, 44 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/83/36983/1

diff --git a/TODO-RELEASE b/TODO-RELEASE
index 4a35f50..7aeffd4 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -8,3 +8,4 @@
 # If any interfaces have been removed or changed since the last public 
release: c:r:0.
 #library       what            description / commit summary line
 libosmocore > 1.9.0    working (compiling)     gsmtap_inst_fd2()
+libosmo-simtrace2 >= 0.9.0 required to compile (sim presence polarity)
diff --git a/configure.ac b/configure.ac
index 0529ff2..570b042 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,7 +65,7 @@
 if test "$osmo_ac_build_client_st2" = "yes"; then
        AC_DEFINE(BUILD_CLIENT_ST2, 1, [Define if we want to build 
osmo-remsim-client-st2])
        PKG_CHECK_MODULES(OSMOUSB, libosmousb >= 1.4.0)
-       PKG_CHECK_MODULES(OSMOSIMTRACE2, libosmo-simtrace2 >= 0.8.0)
+       PKG_CHECK_MODULES(OSMOSIMTRACE2, libosmo-simtrace2 >= 0.9.0)
        PKG_CHECK_MODULES(USB, libusb-1.0)
 fi
 AM_CONDITIONAL(BUILD_CLIENT_ST2, test "x$osmo_ac_build_client_st2" = "xyes")
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index b4d5bd5..f158424 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -32,7 +32,7 @@
 bin_PROGRAMS += osmo-remsim-client-st2
 osmo_remsim_client_st2_SOURCES = user_simtrace2.c remsim_client_main.c \
                                 remsim_client.c main_fsm.c 
../rspro_client_fsm.c ../debug.c
-osmo_remsim_client_st2_CPPFLAGS = -DUSB_SUPPORT
+osmo_remsim_client_st2_CPPFLAGS = -DUSB_SUPPORT -DSIMTRACE_SUPPORT
 osmo_remsim_client_st2_CFLAGS = $(AM_CFLAGS)
 osmo_remsim_client_st2_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) 
$(OSMOABIS_LIBS) \
                               $(OSMOUSB_LIBS) $(OSMOSIMTRACE2_LIBS) \
diff --git a/src/client/client.h b/src/client/client.h
index 8fcbcb3..df95312 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -86,6 +86,13 @@
                int addr;
                char *path;
        } usb;
+
+       /* only valid for simtrace2 devices */
+       struct {
+               /* allow to define sim presence pin behaviour */
+               bool presence_valid;
+               bool presence_pol;
+       } simtrace;
 };

 struct bankd_client {
diff --git a/src/client/remsim_client_main.c b/src/client/remsim_client_main.c
index 372cc92..2f9b8e0 100644
--- a/src/client/remsim_client_main.c
+++ b/src/client/remsim_client_main.c
@@ -36,6 +36,9 @@
                "  -r --atr-ignore-rspro      Ignore any ATR from bankd; use 
only ATR given by -a)\n"
                "  -e --event-script <path>   event script to be called by 
client\n"
                "  -L --disable-color         Disable colors for logging to 
stderr\n"
+#ifdef SIMTRACE_SUPPORT
+               "  -Z --set-sim-presence <0-1> Define the presence pin 
behaviour (only supported on some boards)\n"
+#endif
 #ifdef USB_SUPPORT
                "  -V --usb-vendor VENDOR_ID\n"
                "  -P --usb-product PRODUCT_ID\n"
@@ -79,6 +82,9 @@
                };

                c = getopt_long(argc, argv, "hvd:i:p:c:n:a:re:L"
+#ifdef SIMTRACE_SUPPORT
+                                               "Z:"
+#endif
 #ifdef USB_SUPPORT
                                                "V:P:C:I:S:A:H:"
 #endif
@@ -128,6 +134,12 @@
                case 'L':
                        log_set_use_color(osmo_stderr_target, 0);
                        break;
+#ifdef SIMTRACE_SUPPORT
+               case 'Z':
+                       cfg->simtrace.presence_valid = true;
+                       cfg->simtrace.presence_pol = atoi(optarg);
+                       break;
+#endif
 #ifdef USB_SUPPORT
                case 'V':
                        cfg->usb.vendor_id = strtol(optarg, NULL, 16);
diff --git a/src/client/user_simtrace2.c b/src/client/user_simtrace2.c
index 8dd3423..3bc32e2 100644
--- a/src/client/user_simtrace2.c
+++ b/src/client/user_simtrace2.c
@@ -396,6 +396,7 @@
        struct osmo_st2_transport *transp;
        struct osmo_st2_cardem_inst *ci;
        struct client_config *cfg = bc->cfg;
+       struct cardemu_usb_msg_config cardem_config = { .features = 
CEMU_FEAT_F_STATUS_IRQ };
        int rc, i;

        rc = osmo_libusb_init(NULL);
@@ -456,8 +457,12 @@
        for (i = 0; i < 4; i++)
                allocate_and_submit_in(ci);

-       /* request firmware to generate STATUS on IRQ endpoint */
-       osmo_st2_cardem_request_config(ci, CEMU_FEAT_F_STATUS_IRQ);
+       /* request firmware to generate STATUS on IRQ endpoint, set presence 
polarity */
+       if (cfg->simtrace.presence_valid) {
+               cardem_config.pres_pol = cfg->simtrace.presence_pol ? 
CEMU_CONFIG_PRES_POL_PRES_H : 0;
+               cardem_config.pres_pol |= CEMU_CONFIG_PRES_POL_VALID;
+       }
+       osmo_st2_cardem_request_config2(ci, &cardem_config);

        while (1) {
                osmo_select_main(0);

--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/36983?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: Iaa61967d2e8cd5c2269b73f4e65b42072e0ec513
Gerrit-Change-Number: 36983
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <[email protected]>
Gerrit-MessageType: newchange

Reply via email to