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.

Change-Id: Iacde63e667472a85a5f18cb4ca99dcfa1a84dd59
This commit is contained in:
Alexander Couzens
2024-05-31 16:43:03 +02:00
parent 504c0fab50
commit c79b582000
4 changed files with 28 additions and 3 deletions

View File

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

View File

@@ -41,6 +41,8 @@ struct osmo_st2_cardem_inst {
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_sw_tx(struct osmo_st2_cardem_inst *ci, const uint8_t
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);

View File

@@ -272,6 +272,21 @@ int osmo_st2_cardem_request_config(struct osmo_st2_cardem_inst *ci, uint32_t fea
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
***********************************************************************/

View File

@@ -413,6 +413,7 @@ static void print_help(void)
"\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 @@ static const struct option opts[] = {
{ "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 @@ int main(int argc, char **argv)
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 @@ int main(int argc, char **argv)
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 @@ int main(int argc, char **argv)
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 @@ int main(int argc, char **argv)
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);