Serial read - way to get a millisecond timestamp resolution ?

2 次查看(过去 30 天)
Hi everyone,
I'm currently developping a custom high end serial communication API for various in-house purpose.
I need for this a resolution of the millisecond or tens of milliseconds when reading data.
The simpliest method to do this along the matlab documentation is to set a Callback on BytesAvailableFcn serial object property which fire event when specific terminator is read.
Thus according to the same documentation, the BytesAvailableFcn callback parameters are:
BytesAvailableFcn_Callback(this,serialObj,evt)
The event parameter contains :
Type: 'BytesAvailable'
Data: [1x1 struct]
with Data a one field structure AbsTime: [YYYY m dd HH MM SS]
Therefore, the resolution of the time monitoring is the second.
However using the record property of the serial object, the automatic log performs a millisecond resolution!
My question is: is there anyway to get a millisecond resolution in the BytesAvailable event ?
----------------------------
p.s.
The automatic record way is not suitable for my purpose and there s no possibility to subclassing/modify this (built-in ?) function.
I've also compared the accuracy of time acquisition between automatic record (serial data ready) and a manual now in the BytesAvailable Callback (serial data ready + callback call).
There is a gap in the order of the thousands ms at the first read, then there is a millisecond interval between each method, so it's seem to be a lack of accuracy for me.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by