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

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Jul 11 20:25:01 UTC 2018


Harald Welte has submitted this change and it was merged. ( 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(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/firmware/libcommon/source/sniffer.c b/firmware/libcommon/source/sniffer.c
index 4ec56d9..07bc82d 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: merged
Gerrit-Change-Id: Ie8946894a84cb853b45555f7abb1ca6f32111425
Gerrit-Change-Number: 9921
Gerrit-PatchSet: 6
Gerrit-Owner: Kévin Redon <kredon at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180711/c35f8c70/attachment.htm>


More information about the gerrit-log mailing list