Hello fredo_,
I have now changed the test code. 80,000 bytes should be read in. If 0 is returned, ‘sleep’ waits 100 ms. The error message appears for over 60,000 bytes.
Peter
size_t readBytes = 0;
size_t len = 2000;
length *= sizeof(float); // length is 20.000 Samples * 4 Bytes = 80.000
size_t count = 0;
uint8_t* resultData = (unsigned char*)cap->m_samples.GetCpuPointer();
while(readBytes < length)
{
count += 1;
size_t newBytes = m_transport->ReadRawData(len,resultData+readBytes);
// Add some timeout detection / count of zero returns here to prevent locking on protocol errors
readBytes += newBytes;
if (newBytes == 0)
{
LogDebug("RTB2k: ReadRawData newBytes = 0, readBytes = %li\n", readBytes);
this_thread::sleep_for(c_readrawdata_delay);
}
if ((len * count) > length)
{
LogDebug("RTB2k: ReadRawData break\n");
break;
}
}
LogDebug("RTB2k: ReadRawData count = %li\n", count);
Log:
RTB2k: SCPI-Block Size DATA? -> 80000
ReadRawData: data depleted.
RTB2k: ReadRawData newBytes = 0, readBytes = 62000
ReadRawData: data depleted.
RTB2k: ReadRawData newBytes = 0, readBytes = 62000
ReadRawData: data depleted.
RTB2k: ReadRawData newBytes = 0, readBytes = 62000
ReadRawData: data depleted.
RTB2k: ReadRawData newBytes = 0, readBytes = 62000
ReadRawData: data depleted.
RTB2k: ReadRawData newBytes = 0, readBytes = 62000
ReadRawData: data depleted.
RTB2k: ReadRawData newBytes = 0, readBytes = 62000
ReadRawData: data depleted.
RTB2k: ReadRawData newBytes = 0, readBytes = 62000
ReadRawData: data depleted.
RTB2k: ReadRawData newBytes = 0, readBytes = 62000
ReadRawData: data depleted.
RTB2k: ReadRawData newBytes = 0, readBytes = 62000
ReadRawData: data depleted.
RTB2k: ReadRawData newBytes = 0, readBytes = 62000
RTB2k: ReadRawData break
RTB2k: ReadRawData count = 41
Edit:
I also tested a program where I programmed the USBTMC protocol myself using libusb-1. I can use it to read and save 40 MB in less than 4 seconds.