Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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

1 vue (au cours des 30 derniers jours)
Ryan Miller
Ryan Miller le 27 Fév 2014
Clôturé : MATLAB Answer Bot le 20 Août 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?

Réponses (1)

Walter Roberson
Walter Roberson le 28 Fév 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