Change in simtrace2[master]: sniffer: move data print before USB send

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/.

Kévin Redon gerrit-no-reply at lists.osmocom.org
Sun Jul 8 15:36:22 UTC 2018


Kévin Redon has uploaded this change for review. ( https://gerrit.osmocom.org/9921


Change subject: sniffer: move data print before USB send
......................................................................

sniffer: move data print before USB send

when the host software does not retrieve the USB messages the memory
is filled and no new USB messages can be allocated, preventing the
following code to print the message

Change-Id: Ie8946894a84cb853b45555f7abb1ca6f32111425
---
M firmware/libcommon/source/sniffer.c
1 file changed, 13 insertions(+), 12 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/21/9921/1

diff --git a/firmware/libcommon/source/sniffer.c b/firmware/libcommon/source/sniffer.c
index b78339b..a47ef55 100644
--- a/firmware/libcommon/source/sniffer.c
+++ b/firmware/libcommon/source/sniffer.c
@@ -306,18 +306,6 @@
 	/* Show activity on LED */
 	led_blink(LED_GREEN, BLINK_2O_F);
 
-	/* Send data over USB */
-	struct msgb *usb_msg = usb_msg_alloc_hdr(SIMTRACE_USB_EP_CARD_DATAIN, SIMTRACE_MSGC_SNIFF, type);
-	if (!usb_msg) {
-		return;
-	}
-	struct sniff_data *usb_sniff_data = (struct sniff_data *) msgb_put(usb_msg, sizeof(*usb_sniff_data));
-	usb_sniff_data->flags = flags;
-	usb_sniff_data->length = length;
-	uint8_t *sniff_data = msgb_put(usb_msg, usb_sniff_data->length);
-	memcpy(sniff_data, data, length);
-	usb_msg_upd_len_and_submit(usb_msg);
-
 	/* Print message */
 	switch (type) {
 	case SIMTRACE_MSGT_SNIFF_ATR:
@@ -357,6 +345,19 @@
 		printf("%02x ", data[i]);
 	}
 	printf("\n\r");
+
+	/* Send data over USB */
+	struct msgb *usb_msg = usb_msg_alloc_hdr(SIMTRACE_USB_EP_CARD_DATAIN, SIMTRACE_MSGC_SNIFF, type);
+	if (!usb_msg) {
+		return;
+	}
+	struct sniff_data *usb_sniff_data = (struct sniff_data *) msgb_put(usb_msg, sizeof(*usb_sniff_data));
+	usb_sniff_data->flags = flags;
+	usb_sniff_data->length = length;
+	uint8_t *sniff_data = msgb_put(usb_msg, usb_sniff_data->length);
+	memcpy(sniff_data, data, length);
+	usb_msg_upd_len_and_submit(usb_msg);
+
 }
 
 /*! Send current ATR over USB

-- 
To view, visit https://gerrit.osmocom.org/9921
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie8946894a84cb853b45555f7abb1ca6f32111425
Gerrit-Change-Number: 9921
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon <kredon at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180708/5dc98f83/attachment.htm>


More information about the gerrit-log mailing list