Change in ...osmo-ccid-firmware[master]: card_uart_tx: Allow caller to specify if Rx should be active after Tx

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Wed Oct 9 20:32:03 UTC 2019


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/15743


Change subject: card_uart_tx: Allow caller to specify if Rx should be active after Tx
......................................................................

card_uart_tx: Allow caller to specify if Rx should be active after Tx

This reverts commit 02dd9111635a8adbcd804671695de88f22ffa5ae.

Change-Id: Ibe02d283701dbfff5ab47e1b8195369c134cde03
---
M ccid_common/cuart.c
M ccid_common/cuart.h
M ccid_common/iso7816_fsm.c
M ccid_host/cuart_test.c
4 files changed, 11 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware refs/changes/43/15743/1

diff --git a/ccid_common/cuart.c b/ccid_common/cuart.c
index 4ea82ba..9a68167 100644
--- a/ccid_common/cuart.c
+++ b/ccid_common/cuart.c
@@ -112,7 +112,7 @@
 	return rc;
 }
 
-int card_uart_tx(struct card_uart *cuart, const uint8_t *data, size_t len)
+int card_uart_tx(struct card_uart *cuart, const uint8_t *data, size_t len, bool rx_after_complete)
 {
 	OSMO_ASSERT(cuart);
 	OSMO_ASSERT(cuart->driver);
@@ -121,6 +121,7 @@
 
 	OSMO_ASSERT(!cuart->tx_busy);
 	cuart->tx_busy = true;
+	cuart->rx_after_tx_compl = rx_after_complete;
 	/* disable receiver to avoid receiving what we transmit */
 	card_uart_ctrl(cuart, CUART_CTL_RX, false);
 
@@ -150,7 +151,8 @@
 	case CUART_E_TX_COMPLETE:
 		cuart->tx_busy = false;
 		/* re-enable receiver if we're done with transmit */
-		card_uart_ctrl(cuart, CUART_CTL_RX, true);
+		if (cuart->rx_after_tx_compl)
+			card_uart_ctrl(cuart, CUART_CTL_RX, true);
 		break;
 	default:
 		break;
diff --git a/ccid_common/cuart.h b/ccid_common/cuart.h
index 9d56035..b94eb2c 100644
--- a/ccid_common/cuart.h
+++ b/ccid_common/cuart.h
@@ -62,6 +62,8 @@
 	bool tx_busy;
 	/* is the receiver currently enabled or not? */
 	bool rx_enabled;
+	/* should the receiver automatically be nabled after TX completion? */
+	bool rx_after_tx_compl;
 
 	/*! after how many bytes should we notify the user? If this is '1', we will
 	 *  issue CUART_E_RX_SINGLE; if it is > 1, we will issue CUART_E_RX_COMPLETE */
@@ -98,7 +100,7 @@
 int card_uart_close(struct card_uart *cuart);
 
 /*! Schedule (asynchronous) transmit data via UART; optionally enable Rx after completion */
-int card_uart_tx(struct card_uart *cuart, const uint8_t *data, size_t len);
+int card_uart_tx(struct card_uart *cuart, const uint8_t *data, size_t len, bool rx_after_complete);
 
 /*! Schedule (asynchronous) receive data via UART (after CUART_E_RX_COMPLETE) */
 int card_uart_rx(struct card_uart *cuart, uint8_t *data, size_t len);
diff --git a/ccid_common/iso7816_fsm.c b/ccid_common/iso7816_fsm.c
index e173030..b98e2bb 100644
--- a/ccid_common/iso7816_fsm.c
+++ b/ccid_common/iso7816_fsm.c
@@ -829,7 +829,7 @@
 			 tfp->is_command ? "COMMAND" : "RESPONSE",
 			 osmo_hexdump_nospc((uint8_t *) tpduh, sizeof(*tpduh)));
 		osmo_fsm_inst_state_chg(fi, TPDU_S_TX_HDR, 0, 0);
-		card_uart_tx(ip->uart, (uint8_t *) tpduh, sizeof(*tpduh));
+		card_uart_tx(ip->uart, (uint8_t *) tpduh, sizeof(*tpduh), true);
 		break;
 	default:
 		OSMO_ASSERT(0);
@@ -875,7 +875,7 @@
 		} else if (byte == tpduh->ins) {
 			if (tfp->is_command) {
 				/* transmit all remaining bytes */
-				card_uart_tx(ip->uart, msgb_l2(tfp->tpdu), msgb_l2len(tfp->tpdu));
+				card_uart_tx(ip->uart, msgb_l2(tfp->tpdu), msgb_l2len(tfp->tpdu), true);
 				osmo_fsm_inst_state_chg(fi, TPDU_S_TX_REMAINING, 0, 0);
 			} else {
 				card_uart_set_rx_threshold(ip->uart, tpduh->p3);
@@ -886,7 +886,7 @@
 			if (tfp->is_command) {
 				/* transmit *next*, not first byte */
 				OSMO_ASSERT(msgb_l3len(tfp->tpdu) >= 0);
-				card_uart_tx(ip->uart, msgb_l3(tfp->tpdu), 1);
+				card_uart_tx(ip->uart, msgb_l3(tfp->tpdu), 1, false);
 				osmo_fsm_inst_state_chg(fi, TPDU_S_TX_SINGLE, 0, 0);
 			} else {
 				osmo_fsm_inst_state_chg(fi, TPDU_S_RX_SINGLE, 0, 0);
diff --git a/ccid_host/cuart_test.c b/ccid_host/cuart_test.c
index d4d8faf..0ed6614 100644
--- a/ccid_host/cuart_test.c
+++ b/ccid_host/cuart_test.c
@@ -44,7 +44,7 @@
 static void test_apdu(void)
 {
 	const uint8_t select_mf[] = "\xa0\xa4\x04\x00\x02\x3f\x00";
-	card_uart_tx(&g_cuart, select_mf, 5);
+	card_uart_tx(&g_cuart, select_mf, 5, true);
 
 	osmo_select_main(true);
 	sleep(1);

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/15743
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ibe02d283701dbfff5ab47e1b8195369c134cde03
Gerrit-Change-Number: 15743
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191009/00329201/attachment.htm>


More information about the gerrit-log mailing list