fixed command receiving code

pull/1/head
Clyne 4 years ago
parent 875b6a0620
commit 546fb2d9dc

@ -49,9 +49,11 @@ int main()
while (true) {
if (usbd.active()) {
// Expect to receive a byte command 'packet'.
if (char cmd[3]; usbd.read(&cmd, 3) > 0) {
if (char cmd[3]; usbd.read(&cmd, 1) > 0) {
switch (cmd[0]) {
case 'r': // Read in analog signal
if (usbd.read(&cmd[1], 2) < 2)
break;
if (auto count = std::min(static_cast<unsigned int>(cmd[1] | (cmd[2] << 8)), adc_samples.size()); count > 0) {
adc.getSamples(&adc_samples[0], count);
usbd.write(adc_samples.data(), count * sizeof(adcsample_t));

Loading…
Cancel
Save