Skip to content

Commit f9885fe

Browse files
committed
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
1 parent ec9b0b5 commit f9885fe

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

TODO-RELEASE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
#library what description / commit summary line
1010
simtrace2 API/ABI change osmo_st2_transport new member
1111
simtrace2 API/ABI change cardemu_usb_msg_config new member
12+
simtrace2 API/ABI change add function osmo_st2_cardem_request_config2()

host/include/osmocom/simtrace2/simtrace2_api.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ struct osmo_st2_cardem_inst {
4141
void *priv;
4242
};
4343

44+
struct cardemu_usb_msg_config;
45+
4446
int osmo_st2_slot_tx_msg(struct osmo_st2_slot *slot, struct msgb *msg,
4547
uint8_t msg_class, uint8_t msg_type);
4648

@@ -53,7 +55,7 @@ int osmo_st2_cardem_request_sw_tx(struct osmo_st2_cardem_inst *ci, const uint8_t
5355
int osmo_st2_cardem_request_set_atr(struct osmo_st2_cardem_inst *ci, const uint8_t *atr,
5456
unsigned int atr_len);
5557
int osmo_st2_cardem_request_config(struct osmo_st2_cardem_inst *ci, uint32_t features);
56-
58+
int osmo_st2_cardem_request_config2(struct osmo_st2_cardem_inst *ci, const struct cardemu_usb_msg_config *config);
5759

5860
int osmo_st2_modem_reset_pulse(struct osmo_st2_slot *slot, uint16_t duration_ms);
5961
int osmo_st2_modem_reset_active(struct osmo_st2_slot *slot);

host/lib/simtrace2_api.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,21 @@ int osmo_st2_cardem_request_config(struct osmo_st2_cardem_inst *ci, uint32_t fea
272272
return osmo_st2_slot_tx_msg(ci->slot, msg, SIMTRACE_MSGC_CARDEM, SIMTRACE_MSGT_BD_CEMU_CONFIG);
273273
}
274274

275+
/* user_cfg is in host byte order. */
276+
int osmo_st2_cardem_request_config2(struct osmo_st2_cardem_inst *ci, const struct cardemu_usb_msg_config *user_cfg)
277+
{
278+
struct msgb *msg = st_msgb_alloc();
279+
struct cardemu_usb_msg_config *tx_cfg;
280+
281+
tx_cfg = (struct cardemu_usb_msg_config *) msgb_put(msg, sizeof(*tx_cfg));
282+
283+
LOGSLOT(ci->slot, LOGL_NOTICE, "<= %s(features=%08x)\n", __func__, tx_cfg->features);
284+
memcpy(tx_cfg, user_cfg, sizeof(*tx_cfg));
285+
osmo_store32le(user_cfg->features, &tx_cfg->features);
286+
287+
return osmo_st2_slot_tx_msg(ci->slot, msg, SIMTRACE_MSGC_CARDEM, SIMTRACE_MSGT_BD_CEMU_CONFIG);
288+
}
289+
275290
/***********************************************************************
276291
* Modem Control protocol
277292
***********************************************************************/

host/src/simtrace2-cardem-pcsc.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ static void print_help(void)
413413
"\t-S\t--usb-altsetting ALTSETTING_ID\n"
414414
"\t-A\t--usb-address\tADDRESS\n"
415415
"\t-H\t--usb-path\tPATH\n"
416+
"\t-Z\t--set-sim-presence\t<0/1>\n"
416417
"\n"
417418
);
418419
}
@@ -431,6 +432,7 @@ static const struct option opts[] = {
431432
{ "usb-altsetting", 1, 0, 'S' },
432433
{ "usb-address", 1, 0, 'A' },
433434
{ "usb-path", 1, 0, 'H' },
435+
{ "set-sim-presence", 1, 0, 'Z' },
434436
{ NULL, 0, 0, 0 }
435437
};
436438

@@ -487,6 +489,7 @@ int main(int argc, char **argv)
487489
char *path = NULL;
488490
struct osim_reader_hdl *reader;
489491
struct osim_card_hdl *card;
492+
struct cardemu_usb_msg_config cardem_config = { .features = CEMU_FEAT_F_STATUS_IRQ };
490493

491494
print_welcome();
492495

@@ -509,7 +512,7 @@ int main(int argc, char **argv)
509512
while (1) {
510513
int option_index = 0;
511514

512-
c = getopt_long(argc, argv, "hi:V:P:C:I:S:A:H:akn:t:", opts, &option_index);
515+
c = getopt_long(argc, argv, "hi:V:P:C:I:S:A:H:akn:t:Z:", opts, &option_index);
513516
if (c == -1)
514517
break;
515518
switch (c) {
@@ -553,6 +556,10 @@ int main(int argc, char **argv)
553556
case 'H':
554557
path = optarg;
555558
break;
559+
case 'Z':
560+
cardem_config.pres_pol = atoi(optarg) ? CEMU_CONFIG_PRES_POL_PRES_H : 0;
561+
cardem_config.pres_pol |= CEMU_CONFIG_PRES_POL_VALID;
562+
break;
556563
}
557564
}
558565

@@ -636,7 +643,7 @@ int main(int argc, char **argv)
636643
allocate_and_submit_in(ci);
637644

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

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

0 commit comments

Comments
 (0)