USB serial: maybe a clogged buffer? #3235
JoshuaACNewman
started this conversation in
General
Replies: 1 comment
-
void receiveDACs() {
for (byte thisDACChannel = 0; thisDACChannel < numOutputChannels; thisDACChannel++) {
DACSamplesFromEasel[thisDACChannel] = Serial.parseInt();
}
}Are you sure you want this? The behavior of
I would never ever ever use this function in my own sketch. Waiting for a timeout or an invalid character to arrive seems very fragile to me. What's the input data format? Are they deliminited with something? I would write everything non-blocking, just checking if there are enough bytes received in the serial buffer to start parsing the values in one go. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to track down a weird problem, and it's possible the problem is a constipated USB serial buffer.
The objective: communicate between an RPi Pico2 and a patch running in plugdata. The Pico2 is mounted on a PCB called an Oblique Palette with 8 i2c DACs and 8 multiplexed channels running to one ADC, plus of course their support electronics.
You can see it running here.
Expected Behavior:
What happens:
MacOS: Works okay, but at a sample rate of 40Hz, which is pretty damn slow considering the speed of communication I should be getting. I don't see why I should be getting slower than kilohertz sample rates. Note: I had incorrect pullup values earlier, and the result before that was that it would communicate OK at ~40Hz, then, after a random number of seconds, the Palette would start waiting exactly 4 seconds (minus about 100 µsecs) before continuing.
Linux: Works great for a random number of seconds at ~350Hz, then stops altogether, neither reading nor writing, and the LED status light, which should be switching each time it completes a task, is completely solid, indicating that the µC is not running at all. If I try to close the serial port from the computer side, plugdata hangs, as it is waiting to hear back from the completely frozen serial port. Unplugging the USB immediately restores the patch, and plugging the board back in brings it back to life as normal.
This has been driving me bonkers for almost two months now, and I've solved what seems to be half the problem (needing to switch to surprisingly small i2c pullup resistors), but now something (and I suspect the serial port) is stopping me.
Man, I'd love some help.
Code follows
Beta Was this translation helpful? Give feedback.
All reactions