From a7caba19df030f000f07ffbb910dc96cba289fd6 Mon Sep 17 00:00:00 2001 From: nirenjan Date: Sun, 12 Apr 2020 16:29:22 -0700 Subject: [PATCH] Set debug output to be line buffered The stub libusb library used for testing writes the control request to a dump file. By default, this file is block-buffered, and on a typical Linux system, it waits until it receives about a page worth of data before flushing it to disk. This results in a delay in monitoring packets when running a debug program. This change makes the file line-buffered instead, which results in the debug output for every single packet getting flushed to disk without having to wait for a full page of data. --- lib/libusbx52/usb_x52_stub.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/libusbx52/usb_x52_stub.c b/lib/libusbx52/usb_x52_stub.c index a65de70..9209539 100644 --- a/lib/libusbx52/usb_x52_stub.c +++ b/lib/libusbx52/usb_x52_stub.c @@ -240,6 +240,8 @@ int libusb_open(libusb_device *dev, libusb_device_handle **handle) free(tmp_hdl); return LIBUSB_ERROR_IO; } + /* Set the packet data file to be line buffered */ + setlinebuf(tmp_hdl->packet_data_file); LIBUSB_DUMP_LOG_FILE(tmp_hdl, LIBUSB_LOG_LEVEL_DEBUG, "VID: %04x PID: %04x idx: %d ref: %d\n",