From c6748b5b96b8d268b5dafaacb3a0eef3ab4a5a58 Mon Sep 17 00:00:00 2001 From: Robin Gerzaguet Date: Fri, 12 Apr 2024 11:04:16 +0200 Subject: [PATCH] Correct issue of Q16 overflow for bladeRF --- Project.toml | 2 +- readme.md | 8 +++++++- src/Backends/BladeRF/BladeRFBindings.jl | 15 ++++++++------- src/Scan.jl | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Project.toml b/Project.toml index 238dece..0bf68ec 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "AbstractSDRs" uuid = "0bdde9fc-719a-4dc7-8589-49ca6634fa6b" authors = ["Robin Gerzaguet "] -version = "0.5.0" +version = "0.5.1" [deps] AdalmPluto = "af34ca7c-e544-47d5-a6fe-72495f08728e" diff --git a/readme.md b/readme.md index 5bfab23..a11cabc 100644 --- a/readme.md +++ b/readme.md @@ -79,7 +79,7 @@ If you use `AbstractSDRs.jl` we encourage you to cite this work that you can fin ## Backends -AbstractSDRs wraps and implements different SDR backends that can be used when opening a radio device. The current list of supported SDR backends can be obtained via `getSupportedSDR`. +AbstractSDRs wraps and implements different SDR backends that can be used when opening a radio device. The current list of supported SDR backends can be obtained via `getSupportedSDRs`. When instantiate a radio device (with `openSDR`), the first argument is the radio backend and parameters associated to a specific backend can be used with keywords. Some specific functions can also be exported based in the selected backend. The list is given in the sub-backend part @@ -114,3 +114,9 @@ This backend can be used with ADALM Pluto SDR device. ## Documentation - [**STABLE**](https://juliatelecom.github.io/AbstractSDRs.jl/dev/index.html) — **documentation of the most recently tagged version.** + + + +## Changelog + +- 0.5.1 : Correct potential bug in data overflow for bladeRF backend \ No newline at end of file diff --git a/src/Backends/BladeRF/BladeRFBindings.jl b/src/Backends/BladeRF/BladeRFBindings.jl index 992adcd..719f7c8 100644 --- a/src/Backends/BladeRF/BladeRFBindings.jl +++ b/src/Backends/BladeRF/BladeRFBindings.jl @@ -194,10 +194,11 @@ function openBladeRF(carrierFreq,samplingRate,gain;agc_mode=0,packet_size=4096) # --- Wrap all into a custom structure # ---------------------------------------------------- # Instantiate a buffer to handle async receive. Size is arbritrary and will be modified afterwards - buffer = zeros(Int16,packet_size*2) - bladeRFRx = BladeRFRxWrapper(theChannelRx,buffer,ptr_metadata_rx) - bladeRFTx = BladeRFTxWrapper(theChannelTx,buffer,ptr_metadata_tx) - rx = BladeRFRx( + bufferTx = zeros(Int16,packet_size*2) + bufferRx = zeros(Int16,packet_size*2) + bladeRFRx = BladeRFRxWrapper(theChannelRx,bufferRx,ptr_metadata_rx) + bladeRFTx = BladeRFTxWrapper(theChannelTx,bufferTx,ptr_metadata_tx) + rx = BladeRFRx( bladeRFRx, effective_carrierFreq, effective_sampling_rate, @@ -232,7 +233,7 @@ function Base.print(rx::BladeRFRx); end function Base.print(tx::BladeRFTx); strF = @sprintf("Carrier Frequency: %2.3f MHz\nSampling Frequency: %2.3f MHz\nRF Bandwidth: %2.3f MHz\nGain: %2.3f",tx.carrierFreq/1e6,tx.samplingRate/1e6,tx.rfBandwidth/1e6,tx.gain) - @infotx "Current BladeRF Radio Configuration in Rx mode\n$strF"; + @infotx "Current BladeRF Radio Configuration in Tx mode\n$strF"; end function Base.print(radio::BladeRFBinding) print(radio.rx); @@ -421,8 +422,8 @@ end function _fill_tx_buffer!(internal_buffer,buffer,offset,nI) vM = typemax(Int16) @inbounds @simd for k ∈ 1 : nI - internal_buffer[2*(k-1)+1] = Int16(round(real(buffer[ offset + k] * vM))) - internal_buffer[2*(k-1)+2] = Int16(round(imag(buffer[ offset + k] * vM))) + internal_buffer[2*(k-1)+1] = Int16(round(real(buffer[ offset + k] * vM))) >> 4 + internal_buffer[2*(k-1)+2] = Int16(round(imag(buffer[ offset + k] * vM))) >> 4 end return nothing end diff --git a/src/Scan.jl b/src/Scan.jl index ce5e6ce..fb8f8a4 100644 --- a/src/Scan.jl +++ b/src/Scan.jl @@ -11,7 +11,7 @@ Scan interface and returns the founded SDR sdr = scan() sdr = scan(backend;key...) # Input parameter -If the function is called without parameters il will search for all avaliable backends such as UHDBindings and AdalmPluto. Otherwise the search will be limited to the desired backend +If the function is called without parameters il will search for all available backends such as UHDBindings and AdalmPluto. Otherwise the search will be limited to the desired backend The optionnal arguments are the one supported by UHDBindings and AdalmPluto. See `uhd_find_devices()` in UHDBindings and `scan` function in AdalmPluto # Keywords - args : String used in UHD backend to specify USRP IP address. Example: scan(:uhd;args="addr=192.168.10.16")