How to resolce callback error : asyncio.Ch​annel/onDa​taReceived ....line(487):::

12 ビュー (過去 30 日間)
Samuel Olufemi Taiwo
Samuel Olufemi Taiwo 2021 年 3 月 21 日
編集済み: LO 2021 年 7 月 14 日
I am trying to get MATLAB to read a stream of incoming data via a serial port using callback ,
This is a peice of my code
s = serialport("COM4", 115200)
function readSerialData(src,evt)
src.UserData = data;
end
Whenever I type readline(S), I get a one time result but I want it to be automatic whenever a new stream of data arrive, hence my use of callback function.
So whenver I type
configureCallback ("COM4", "terminator" , @ readSerialData)
I get a non stopping error:
Error in asyncio.Channel/onDataReceived (line 487)
notify(obj.InputStream, 'DataWritten', ...
Error in asyncio.Channel>@(source,data)obj.onDataReceived() (line 425)
@(source, data) obj.onDataReceived());
> In asyncio/Channel/onDataReceived (line 487)
In asyncio.Channel>@(source,data)obj.onDataReceived() (line 425)
>>

回答 (1 件)

LO
LO 2021 年 7 月 14 日
編集済み: LO 2021 年 7 月 14 日
I had the same problem. Check if you have two listeners (or also function callbacks) aiming at the same data stream.
For me that was the issue.

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by