Skip to content

Commit 095329e

Browse files
author
Robin Gerzaguet
committed
Ensure that late packet does not freeze the engine
1 parent 0647a29 commit 095329e

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/Rx.jl

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ recv!(sig,radio,nbSamples)
258258
-
259259
"""
260260
function recv!(sig::Vector{Vector{Complex{T}}},radio::UHDRx;nbSamples=0,offset=0) where T
261-
# restartStreamer(radio)
261+
#restartStreamer(radio)
262262
# --- Defined parameters for multiple buffer reception
263263
filled = false;
264264
# --- Fill the input buffer @ a specific offset
@@ -320,24 +320,28 @@ function populateBuffer!(radio,ptr,nbSamples::Csize_t=0)
320320
#@assert nbSamples <= length(buffer.x) "Number of desired samples can not be greater than buffer size";
321321
# --- Effectively recover data
322322
pointerSamples = Ref{Csize_t}(0);
323-
uhd_rx_streamer_recv(radio.uhd.pointerStreamer,ptr,nbSamples,radio.uhd.addressMD,0.1,false,pointerSamples)
323+
radio.checkErrors = true
324+
uhd_rx_streamer_recv(radio.uhd.pointerStreamer,ptr,nbSamples,radio.uhd.addressMD,1,false,pointerSamples)
324325
# --- Check for errors
325326
if radio.checkErrors && pointerSamples[] == 0
326327
err = getError(radio)
327328
if err != UHD_RX_METADATA_ERROR_CODE_NONE && err != UHD_RX_METADATA_ERROR_CODE_TIMEOUT
329+
#println(".")
328330
if err == UHD_RX_METADATA_ERROR_CODE_LATE_COMMAND
329-
throw(LateCommandException())
330-
elseif err == UHD_RX_METADATA_ERROR_CODE_BROKEN_CHAIN
331-
throw(BrokenChainException())
332-
elseif err == UHD_RX_METADATA_ERROR_CODE_OVERFLOW
333-
throw(OverflowException())
334-
elseif err == UHD_RX_METADATA_ERROR_CODE_ALIGNMENT
335-
throw(AlignmentException())
336-
elseif err == UHD_RX_METADATA_ERROR_CODE_BAD_PACKET
337-
throw(BadPacketException())
338-
else
339-
# This should be unreachable
340-
@warn "Unexpected UHD error code: $err"
331+
println("Late received packet < restart streamer >")
332+
restartStreamer(radio)
333+
#throw(LateCommandException())
334+
# elseif err == UHD_RX_METADATA_ERROR_CODE_BROKEN_CHAIN
335+
# #throw(BrokenChainException())
336+
# elseif err == UHD_RX_METADATA_ERROR_CODE_OVERFLOW
337+
# #throw(OverflowException())
338+
# elseif err == UHD_RX_METADATA_ERROR_CODE_ALIGNMENT
339+
# #throw(AlignmentException())
340+
# elseif err == UHD_RX_METADATA_ERROR_CODE_BAD_PACKET
341+
# #throw(BadPacketException())
342+
# else
343+
# # This should be unreachable
344+
# @warn "Unexpected UHD error code: $err"
341345
end
342346
end
343347
end

0 commit comments

Comments
 (0)