Skip to content

I can't make write work #113

@sgaure

Description

@sgaure

When doing a write on a Tx stream I get an error:

    nested task error: MethodError: no method matching unsafe_convert(::Type{Ptr{Int32}}, ::Nothing)
    The function `unsafe_convert` exists, but no method is defined for this combination of argument types.
    
    Closest candidates are:
      unsafe_convert(::Type{Cwstring}, ::Any)
       @ Base strings/cstring.jl:101
      unsafe_convert(::Type{Ptr{T}}, ::Atomic{T}) where T
       @ Base atomics.jl:335
      unsafe_convert(::Type{Ptr{T}}, ::Array{T}) where T
       @ Base pointer.jl:65
      ...
    
    Stacktrace:
     [1] (::SoapySDR.var"#SoapySDRDevice_writeStream##0#SoapySDRDevice_writeStream##1"{Device, SoapySDR.Stream{ComplexF32}, Ptr{Ptr{ComplexF32}}, Int64, Nothing, Int64, Float64})()
       @ SoapySDR ~/.julia/packages/SoapySDR/adLbS/src/errors.jl:35
     [2] with_error_check(f::SoapySDR.var"#SoapySDRDevice_writeStream##0#SoapySDRDevice_writeStream##1"{Device, SoapySDR.Stream{ComplexF32}, Ptr{Ptr{ComplexF32}}, Int64, Nothing, Int64, Float64})
       @ SoapySDR ~/.julia/packages/SoapySDR/adLbS/src/errors.jl:25
     [3] macro expansion
       @ ~/.julia/packages/SoapySDR/adLbS/src/errors.jl:34 [inlined]
     [4] SoapySDRDevice_writeStream(device::Device, stream::SoapySDR.Stream{ComplexF32}, buffs::Ptr{Ptr{ComplexF32}}, numElems::Int64, flags::Nothing, timeNs::Int64, timeoutUs::Float64)
       @ SoapySDR ~/.julia/packages/SoapySDR/adLbS/src/libsoapysdr.jl:848
     [5] write(s::SoapySDR.Stream{ComplexF32}, buffers::Vector{Vector{ComplexF32}}; timeout::Nothing, flags::Nothing, throw_error::Bool)
       @ SoapySDR ~/.julia/packages/SoapySDR/adLbS/src/device/stream.jl:330
     [6] write
       @ ~/.julia/packages/SoapySDR/adLbS/src/device/stream.jl:306 [inlined]

It seems the problem is in

out_flags = Ref{Cint}(0)
nwritten = SoapySDRDevice_writeStream(
s.d,
s,
buff_ptrs,
samples_to_write - total_nwritten,
flags,
0,
timeout_us,
)
if flags isa Ref
flags[] |= out_flags[]
end

Shouldn't the newly created out_flags appear on line 335, not flags.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions