Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python API] Incompatible Function Arguments #779

Closed
CarlosD1119 opened this issue Aug 15, 2024 · 2 comments
Closed

[Python API] Incompatible Function Arguments #779

CarlosD1119 opened this issue Aug 15, 2024 · 2 comments

Comments

@CarlosD1119
Copy link

Issue Description

I am using usrp to transmit signals with python API. The code is as follows. I don't find out any misaligned arguments, but there are mistakes.

Code:

import uhd
import numpy as np

usrp = uhd.usrp.MultiUSRP()
st_args = uhd.usrp.StreamArgs("fc32", "sc16")
st_args.channels = [0]
tx_streamer = usrp.get_tx_stream(st_args)
md_tx = uhd.types.TXMetadata
md_tx.has_time_spec = False
samples = 0.1*np.random.randn(10000) + 0.1j*np.random.randn(10000) # create random signal
tx_streamer.send(samples, md_tx)

Result:

  File "/home/iiot/PycharmProjects/usrp_tx/new_main.py", line 11, in <module>
    tx_streamer.send(samples, md_tx)
TypeError: send(): incompatible function arguments. The following argument types are supported:
    1. (self: uhd.libpyuhd.usrp.tx_streamer, np_array: object, metadata: uhd.libpyuhd.types.tx_metadata, timeout: float = 0.1) -> int

Invoked with: <uhd.libpyuhd.usrp.tx_streamer object at 0x7f58aed521f0>, array([ 0.05122881-0.02905669j,  0.06272389+0.04570414j,
        0.10575979-0.08321157j, ..., -0.07249551+0.04663707j,
       -0.05430126-0.1516733j , -0.12245535-0.02743819j]), <class 'uhd.libpyuhd.types.tx_metadata'>```
@NI-LAm
Copy link
Contributor

NI-LAm commented Aug 15, 2024

Here:
md_tx = uhd.types.TXMetadata
you do not create a TXMetadata object but you use the underlying pybind11 class, which is not a valid parameter for the streamer send method. Instead you need:
md_tx = uhd.types.TXMetadata()
mind the brackets which will create an instance of the object instead of assigning the class to md_tx!
Then you have a real metadata object and your code should work.

@NI-LAm NI-LAm closed this as completed Aug 15, 2024
@CarlosD1119
Copy link
Author

It works. Many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants