laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/36982?usp=email )

Change subject: simtrace2-cardem-pcsc: allow to set sim presence polarity
......................................................................

simtrace2-cardem-pcsc: allow to set sim presence polarity

Add api call osmo_st2_cardem_request_config2(struct cardemu_usb_msg_config *)
which contains a full cardemu_usb_msg_config.

Related: SYS#6946
Change-Id: Iacde63e667472a85a5f18cb4ca99dcfa1a84dd59
---
M TODO-RELEASE
M host/include/osmocom/simtrace2/simtrace2_api.h
M host/lib/simtrace2_api.c
M host/src/simtrace2-cardem-pcsc.c
4 files changed, 41 insertions(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved




diff --git a/TODO-RELEASE b/TODO-RELEASE
index fb35723..3b33942 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -9,3 +9,4 @@
 #library       what                    description / commit summary line
 simtrace2      API/ABI change          osmo_st2_transport new member
 simtrace2      API/ABI change          cardemu_usb_msg_config new member
+simtrace2      API/ABI change          add function 
osmo_st2_cardem_request_config2()
diff --git a/host/include/osmocom/simtrace2/simtrace2_api.h 
b/host/include/osmocom/simtrace2/simtrace2_api.h
index d658d16..a29389c 100644
--- a/host/include/osmocom/simtrace2/simtrace2_api.h
+++ b/host/include/osmocom/simtrace2/simtrace2_api.h
@@ -41,6 +41,8 @@
        void *priv;
 };

+struct cardemu_usb_msg_config;
+
 int osmo_st2_slot_tx_msg(struct osmo_st2_slot *slot, struct msgb *msg,
                          uint8_t msg_class, uint8_t msg_type);

@@ -53,7 +55,7 @@
 int osmo_st2_cardem_request_set_atr(struct osmo_st2_cardem_inst *ci, const 
uint8_t *atr,
                                    unsigned int atr_len);
 int osmo_st2_cardem_request_config(struct osmo_st2_cardem_inst *ci, uint32_t 
features);
-
+int osmo_st2_cardem_request_config2(struct osmo_st2_cardem_inst *ci, const 
struct cardemu_usb_msg_config *config);

 int osmo_st2_modem_reset_pulse(struct osmo_st2_slot *slot, uint16_t 
duration_ms);
 int osmo_st2_modem_reset_active(struct osmo_st2_slot *slot);
diff --git a/host/lib/simtrace2_api.c b/host/lib/simtrace2_api.c
index 4ad7eb7..37be08a 100644
--- a/host/lib/simtrace2_api.c
+++ b/host/lib/simtrace2_api.c
@@ -272,6 +272,21 @@
        return osmo_st2_slot_tx_msg(ci->slot, msg, SIMTRACE_MSGC_CARDEM, 
SIMTRACE_MSGT_BD_CEMU_CONFIG);
 }

+/* user_cfg is in host byte order. */
+int osmo_st2_cardem_request_config2(struct osmo_st2_cardem_inst *ci, const 
struct cardemu_usb_msg_config *user_cfg)
+{
+       struct msgb *msg = st_msgb_alloc();
+       struct cardemu_usb_msg_config *tx_cfg;
+
+       tx_cfg = (struct cardemu_usb_msg_config *) msgb_put(msg, 
sizeof(*tx_cfg));
+
+       LOGSLOT(ci->slot, LOGL_NOTICE, "<= %s(features=%08x)\n", __func__, 
tx_cfg->features);
+       memcpy(tx_cfg, user_cfg, sizeof(*tx_cfg));
+       osmo_store32le(user_cfg->features, &tx_cfg->features);
+
+       return osmo_st2_slot_tx_msg(ci->slot, msg, SIMTRACE_MSGC_CARDEM, 
SIMTRACE_MSGT_BD_CEMU_CONFIG);
+}
+
 /***********************************************************************
  * Modem Control protocol
  ***********************************************************************/
diff --git a/host/src/simtrace2-cardem-pcsc.c b/host/src/simtrace2-cardem-pcsc.c
index 4acf268..f26698e 100644
--- a/host/src/simtrace2-cardem-pcsc.c
+++ b/host/src/simtrace2-cardem-pcsc.c
@@ -413,6 +413,7 @@
                "\t-S\t--usb-altsetting ALTSETTING_ID\n"
                "\t-A\t--usb-address\tADDRESS\n"
                "\t-H\t--usb-path\tPATH\n"
+               "\t-Z\t--set-sim-presence\t<0/1>\n"
                "\n"
                );
 }
@@ -431,6 +432,7 @@
        { "usb-altsetting", 1, 0, 'S' },
        { "usb-address", 1, 0, 'A' },
        { "usb-path", 1, 0, 'H' },
+       { "set-sim-presence", 1, 0, 'Z' },
        { NULL, 0, 0, 0 }
 };

@@ -487,6 +489,7 @@
        char *path = NULL;
        struct osim_reader_hdl *reader;
        struct osim_card_hdl *card;
+       struct cardemu_usb_msg_config cardem_config = { .features = 
CEMU_FEAT_F_STATUS_IRQ };

        print_welcome();

@@ -509,7 +512,7 @@
        while (1) {
                int option_index = 0;

-               c = getopt_long(argc, argv, "hi:V:P:C:I:S:A:H:akn:t:", opts, 
&option_index);
+               c = getopt_long(argc, argv, "hi:V:P:C:I:S:A:H:akn:t:Z:", opts, 
&option_index);
                if (c == -1)
                        break;
                switch (c) {
@@ -553,6 +556,10 @@
                case 'H':
                        path = optarg;
                        break;
+               case 'Z':
+                       cardem_config.pres_pol = atoi(optarg) ? 
CEMU_CONFIG_PRES_POL_PRES_H : 0;
+                       cardem_config.pres_pol |= CEMU_CONFIG_PRES_POL_VALID;
+                       break;
                }
        }

@@ -636,7 +643,7 @@
                        allocate_and_submit_in(ci);

                /* request firmware to generate STATUS on IRQ endpoint */
-               osmo_st2_cardem_request_config(ci, CEMU_FEAT_F_STATUS_IRQ);
+               osmo_st2_cardem_request_config2(ci, &cardem_config);

                /* simulate card-insert to modem (owhw, not qmod) */
                osmo_st2_cardem_request_card_insert(ci, true);

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Iacde63e667472a85a5f18cb4ca99dcfa1a84dd59
Gerrit-Change-Number: 36982
Gerrit-PatchSet: 7
Gerrit-Owner: lynxis lazus <lyn...@fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-MessageType: merged

Reply via email to