Skip to content

Commit

Permalink
Fix to prevent loss of first 2 frames during capture (due to the init…
Browse files Browse the repository at this point in the history
…ial FPGA buffer flush)
  • Loading branch information
simoninns committed Dec 26, 2017
1 parent 3916f85 commit 358ac37
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Linux-Application/DomesdayDuplicator/QtUsb/qlibusb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ qint32 QUsbDevice::startBulkTransfer(bool testMode, QString fileName)
mUsbBulkTransfer->setup(mCtx, mDevHandle, mConfig.readEp, testMode, fileName);
mUsbBulkTransfer->start();

// Wait for the transfer to start
while(!mUsbBulkTransfer->isTransferRunning());

return rc;
}

Expand Down
13 changes: 13 additions & 0 deletions Linux-Application/DomesdayDuplicator/QtUsb/qusbbulktransfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ struct statisticsStruct {
};
static statisticsStruct statistics;

// Flag to show if transfer is in progress
bool transferRunning;

// Notes:
//
// The ADC generates data at a rate of around 64Mbytes/sec
Expand Down Expand Up @@ -126,6 +129,7 @@ QUsbBulkTransfer::QUsbBulkTransfer(void)
{
stopUsbTransfers = false;
stopDiskTransfers = false;
transferRunning = false;
qDebug() << "QUsbBulkTransfer::QUsbBulkTransfer(): Called";
}

Expand Down Expand Up @@ -164,6 +168,11 @@ void QUsbBulkTransfer::setup(libusb_context* mCtx, libusb_device_handle* devHand
captureFileName = fileName;
}

// Return true if transfer is running
bool QUsbBulkTransfer::isTransferRunning(void) {
return transferRunning;
}

void QUsbBulkTransfer::run()
{
// These variables are referenced by the callback and must remain valid
Expand Down Expand Up @@ -191,6 +200,7 @@ void QUsbBulkTransfer::run()
gettimeofday(&statistics.startTimestamp, NULL);

// Reset transfer variables
transferRunning = false;
transfersInFlight = 0; // Number of transfers that are in progress (global)
requestSize = REQUEST_SIZE; // Request size (number of packets)
packetSize = PACKET_SIZE; // Maximum packet size for the endpoint (in bytes)
Expand Down Expand Up @@ -588,6 +598,9 @@ static void LIBUSB_CALL bulkTransferCallback(struct libusb_transfer *transfer)
statistics.startTimestamp = endTimestamp;
}

// If the buffer flush is complete, flag the transfer as running
if (bufferFlushComplete) transferRunning = true;

// Write received data to disk (unless we are performing a buffer flush)
if (bufferFlushComplete) {
// Disk buffer handling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class QUsbBulkTransfer : public QThread {
quint32 getTestFailureCounter(void);
quint32 getAvailableDiskBuffers(void);
quint32 getNumberOfDiskBuffers(void);
bool isTransferRunning(void);

signals:

Expand Down

0 comments on commit 358ac37

Please sign in to comment.