Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

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

조회 수: 1 (최근 30일)
Ryan Miller
Ryan Miller 2014년 2월 27일
마감: MATLAB Answer Bot 2021년 8월 20일
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?

답변 (1개)

Walter Roberson
Walter Roberson 2014년 2월 28일
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