02-07-2023 10:42 AM
I see your code is enqueuing data even when there isn't any (bytes at port = 0). You should move the enqueue into where you are receiving data. And that's the other thing. Even though that is the way the (ugh) LabVIEW example shows you how to do it, using bytes at port to decide how many bytes to read is a dangerous thing because if the amount actually changes in between bytes at port and the serial read, you'll miss some data if it is the last read. Maybe this is what is causing the USB loop to seem to have delays? there's always a better way than this, but how you do it depends on ho the messages arrive.