-
Notifications
You must be signed in to change notification settings - Fork 38
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
USRP sc16
, sc8
CPU format in Python API
#21
Comments
Oh nice find!!! Any interest in adding it to a new section at the end of the USRP chapter? If not I can, might take a few weeks to get to it though. |
I'm glad to! maybe I can make a PR this weekend. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First, thanks for the great book! It helps me a lot to get started in SDR.
In the USRP chapter, you said that the UHD only supports
fc64
andfc32
CPU data types when using the Python API. In my experiment, I found that all CPU data types are supported in python api, though you need to do some extra job when using thesc16
orsc8
as CPU format.In short, the following codes can be use to rx and tx data with
sc16
CPU data type in python.Receiving
When using
sc8
as CPU format, therecv_buffer
needs to be initialized asnp.int16
, and be viewed asnp.int8
after receiving samples.Transmitting
When using
sc8
as CPU format, thedata
needs to be initialized asnp.int8
, be set vianp.real/imag(samples) * 2 ** 7
, and be viewed asnp.int16
before sending.Why the code works?
Here is the underlying code of
tx_streamer.send(nparr, md)
in the UHD library. It shows that the UHD library only get the underlying bytes of the input numpy array and pass it to the cpp api, which means (I guess) we can use any numpy array as the input of thetx_streamer.send
as long as the item size of the numpy array is same as the CPU format. So when usingsc16
as CPU format, the input numpy array can benp.int32
ornp.uint32
, and when usingsc8
as CPU format, the input numpy array can benp.int16
ornp.uint16
.The C version of tx example also shows that the UHD library only cares about the underlying bytes of the input buffer.
The text was updated successfully, but these errors were encountered: