aboutsummaryrefslogtreecommitdiffstats
path: root/gui/stmdsp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/stmdsp.cpp')
-rw-r--r--gui/stmdsp.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/gui/stmdsp.cpp b/gui/stmdsp.cpp
index 3de3324..2091d48 100644
--- a/gui/stmdsp.cpp
+++ b/gui/stmdsp.cpp
@@ -84,10 +84,26 @@ namespace stmdsp
std::vector<adcsample_t> device::continuous_read() {
if (connected()) {
- m_serial.write("a");
- std::vector<adcsample_t> data (2048);
- m_serial.read(reinterpret_cast<uint8_t *>(data.data()), 2048 * sizeof(adcsample_t));
- return data;
+ m_serial.write("s");
+ unsigned char sizebytes[2];
+ m_serial.read(sizebytes, 2);
+ unsigned int size = sizebytes[0] | (sizebytes[1] << 8);
+ if (size > 0) {
+ std::vector<adcsample_t> data (size);
+ unsigned int total = size * sizeof(adcsample_t);
+ unsigned int offset = 0;
+
+ while (total > 512) {
+ m_serial.read(reinterpret_cast<uint8_t *>(&data[0]) + offset, 512);
+ m_serial.write("n");
+ offset += 512;
+ total -= 512;
+ }
+ m_serial.read(reinterpret_cast<uint8_t *>(&data[0]) + offset, total);
+ m_serial.write("n");
+ return data;
+
+ }
}
return {};