Error occurred while executing the listener callback for event DataWritten defined for class asyncio.InputStream
27 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sugandh Pratap Singh
el 11 de Feb. de 2022
Comentada: ryan mao
el 5 de Ag. de 2024
Hi,
I am reading data over TCP/IP from hardware device using
t1=tcpclient("xxxx",xxxx)
I am configuring callback function, so that when ever 210 data byes avaible to read function1() execute.
while t1.BytesAvailable == 0
%wait for data
end
configureCallback(t1,"byte",210,@varargin()function1())
function function1()
Bytes_DATAF1=t1.NumBytesAvailable
DATA=read(t1,210);
decode=swapbytes(typecast(uint8(DATAF1(1,7:10)'),'uint32'));
Bytes_DATAF2=t1.NumBytesAvailable
end
codes doing fine but in middle giving following warning.
Warning: Error occurred while executing the listener callback for event DataWritten
defined for class asyncio.InputStream:
Error using +
Integers can only be combined with integers of the same class, or scalar doubles.
Error in matlabshared.network.internal.TCPClient/onDataReceived
Error in
matlabshared.network.internal.TCPClient>@(varargin)obj.onDataReceived(varargin{:})
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)
--------------------------------------------------------------------------------------------------------
function function1()
Bytes_DATAF1=t1.NumBytesAvailable
DATA=read(t1,210);
decode=swapbytes(typecast(uint8(DATAF1(1,7:10)'),'uint32'));
Bytes_DATAF2=t1.NumBytesAvailable
end
bytes availabe to read
t1.BytesAvailable=Bytes_DATAF1 =12810
mycode reads only 210 bytes
bytes remaining to read
t1.BytesAvailable=Bytes_DATAF2 = 255
12810-255=12555 bytes missing.
2 comentarios
M. A. Hopcroft
el 14 de Feb. de 2022
It looks like there is a typo with "function1" and "function11"
Respuesta aceptada
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!