Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

How can I know how long data has been sitting in a serial buffer?

1 Ansicht (letzte 30 Tage)
Ryan Miller
Ryan Miller am 27 Feb. 2014
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
I'm sending data from an Arduino (which measures 3D orientation) to a PC via Bluetooth (serial port on PC). I want to know precisely (+/- 5 ms) when events occur on the Arduino. I read in the data with MATLAB more or less continuously with fread, but I don't know how long it took to go from the Arduino writing to the serial buffer to MATLAB reading from the serial buffer. This delay seems to be variable +/- 30ms or so. Is there some way of knowing how long the data has been sitting in the buffer?
I'd like to be able to do some calculation like (current PC time) - (time sitting in buffer) = (time when event occurred). Is there any way to do this or at least cut down the variability?

Antworten (1)

Walter Roberson
Walter Roberson am 28 Feb. 2014
If you are using a true serial port or if you are using a USB virtual serial port or if you are using a Bluetooth virtual serial port, then none of those timestamp the inputs. To timestamp you need a data acquisition device such as one made by National Instruments.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by