Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import file had a max 4MB header size limit before it would fail. Thi… #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 32 additions & 20 deletions pv/devices/inputfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,27 @@ void InputFile::open()

vector<char> buffer(BufferSize);

f->read(buffer.data(), BufferSize);
const streamsize size = f->gcount();
do {
if (!f->eof()) {
f->read(buffer.data(), BufferSize);
const streamsize size = f->gcount();

if (size == 0)
throw QString("Failed to read file");
if (size == 0)
throw QString("Failed to read file");

input_->send(buffer.data(), size);
input_->send(buffer.data(), size);
}

try {
device_ = input_->device();
} catch (sigrok::Error& e) {
throw e;
}
try {
// If this succeeds then enough of the file was read in to create the device.
device_ = input_->device();
} catch (sigrok::Error& e) {
// Failed so may need more of file in order to successfully create the device.
// If already read in all of the file, then throw error.
if (f->eof())
throw e;
}
} while(!device_);

session_->add_device(device_);
}
Expand All @@ -169,19 +177,23 @@ void InputFile::run()
input_->reset();
}

vector<char> buffer(BufferSize);
// May already be at eof due to processing inside open().
// If this is the case we don't want to do any more send() calls.
if (!f->eof()) {
vector<char> buffer(BufferSize);

interrupt_ = false;
while (!interrupt_ && !f->eof()) {
f->read(buffer.data(), BufferSize);
const streamsize size = f->gcount();
if (size == 0)
break;
interrupt_ = false;
while (!interrupt_ && !f->eof()) {
f->read(buffer.data(), BufferSize);
const streamsize size = f->gcount();
if (size == 0)
break;

input_->send(buffer.data(), size);
input_->send(buffer.data(), size);

if (size != BufferSize)
break;
if (size != BufferSize)
break;
}
}

input_->end();
Expand Down