summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Fiore <mfiore@multitech.com>2015-12-07 15:53:41 -0600
committerMike Fiore <mfiore@multitech.com>2015-12-07 15:53:41 -0600
commit5a74150c78737daf2764570835b59b45141f3775 (patch)
treec020d47fb55e99745bcac417d486d54061a1ec33
parentdcd1e5ac988a15bae3fcb9269f4495a7fb5f9215 (diff)
downloadmtdot-box-evb-factory-firmware-5a74150c78737daf2764570835b59b45141f3775.tar.gz
mtdot-box-evb-factory-firmware-5a74150c78737daf2764570835b59b45141f3775.tar.bz2
mtdot-box-evb-factory-firmware-5a74150c78737daf2764570835b59b45141f3775.zip
fix bug where Mode could parse incorrect sweep index
-rw-r--r--Mode/Mode.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/Mode/Mode.cpp b/Mode/Mode.cpp
index f6223d8..70a3f49 100644
--- a/Mode/Mode.cpp
+++ b/Mode/Mode.cpp
@@ -193,10 +193,12 @@ uint32_t Mode::getIndex(DataType type) {
return 0;
}
logInfo("read %d bytes [%s]", ret, buf);
+ bytes_read = file.size - read_offset - 1;
+ logInfo("read %d total bytes", bytes_read);
// read_size - 1 is the last byte in the buffer
for (current = read_size - 1; current >= 0; current--) {
- if ((buf[current] == '\n' && current != read_size - 1) || current == 0) {
+ if ((buf[current] == '\n' && current != read_size - 1) || (current == 0 && bytes_read >= file.size)) {
int test = current;
logInfo("found potential %d, %c", read_offset + current, buf[test + 1]);
if (buf[test + 1] == search) {