Simulink real time I/0 mode
Show older comments
Hi I'm using simulink in SDRT I/0 mode to visualize and analyze my signal.

I use the packet input and a matlab function to parse the data

and this is the function
function [ch1, ch2, valid] = parsePacketBuffered(pkt, ready)
%#codegen
persistent buf
if isempty(buf)
buf = zeros(1, 100, 'uint8');
end
ch1 = int32(0);
ch2 = int32(0);
valid = false;
if ~ready
return;
end
m = length(pkt);
if m >= length(buf)
buf(:) = pkt(end-length(buf)+1:end);
else
buf(1:end-m) = buf(m+1:end);
buf(end-m+1:end) = pkt;
end
% cerca l'ULTIMO frame valido, non il primo
for i = (length(buf)-9):-1:1
if buf(i) == uint8(123) && buf(i+9) == uint8(125)
raw1 = uint32(buf(i+1)) + ...
bitshift(uint32(buf(i+2)), 8) + ...
bitshift(uint32(buf(i+3)), 16) + ...
bitshift(uint32(buf(i+4)), 24);
raw2 = uint32(buf(i+5)) + ...
bitshift(uint32(buf(i+6)), 8) + ...
bitshift(uint32(buf(i+7)), 16) + ...
bitshift(uint32(buf(i+8)), 24);
ch1 = typecast(raw1, 'int32');
ch2 = typecast(raw2, 'int32');
valid = true;
return;
end
end
PROBLEM IS: there is a 1.5s latency between the plot in simulink and the same plot done in phyton. What can be the issue? What am I missing?
Answers (0)
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!