From 3dd57491b1e81a9d93054eff19ca0e6c65c85b9b Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sat, 20 Nov 2021 14:29:08 -0500 Subject: fixed signal generator input data streaming --- source/communication.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'source/communication.cpp') diff --git a/source/communication.cpp b/source/communication.cpp index ec02a42..b5ee28e 100644 --- a/source/communication.cpp +++ b/source/communication.cpp @@ -112,22 +112,23 @@ void updateGenerator(unsigned char *cmd) if (EM.assert(USBSerial::read(&cmd[1], 2) == 2, Error::BadParamSize)) { unsigned int count = cmd[1] | (cmd[2] << 8); if (EM.assert(count <= MAX_SAMPLE_BUFFER_SIZE, Error::BadParam)) { - if (run_status == RunStatus::Idle) { + if (!DAC::isSigGenRunning()) { Samples::Generator.setSize(count); USBSerial::read( reinterpret_cast(Samples::Generator.data()), Samples::Generator.bytesize()); - } else if (run_status == RunStatus::Running) { - int more; - do { - chThdSleepMicroseconds(10); - more = DAC::sigGenWantsMore(); - } while (more == -1); - - // Receive streamed samples in half-buffer chunks. - USBSerial::read(reinterpret_cast( - more == 0 ? Samples::Generator.data() : Samples::Generator.middata()), - Samples::Generator.bytesize() / 2); + } else { + const int more = DAC::sigGenWantsMore(); + if (more == -1) { + USBSerial::write(reinterpret_cast("\0"), 1); + } else { + USBSerial::write(reinterpret_cast("\1"), 1); + + // Receive streamed samples in half-buffer chunks. + USBSerial::read(reinterpret_cast( + more == 0 ? Samples::Generator.data() : Samples::Generator.middata()), + Samples::Generator.bytesize() / 2); + } } } } -- cgit v1.2.3