Shuffled some files around to clean things up a bit
This commit is contained in:
parent
6212546315
commit
1974dd8605
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ __pycache__/
|
|||||||
dependencies/
|
dependencies/
|
||||||
*.log
|
*.log
|
||||||
*.wav
|
*.wav
|
||||||
|
*.raw
|
||||||
|
|||||||
45
example.py
45
example.py
@ -1,45 +0,0 @@
|
|||||||
#! /usr/bin/env python3
|
|
||||||
|
|
||||||
#
|
|
||||||
# Example script for interfacing with SDRPlay radio.
|
|
||||||
#
|
|
||||||
# Modified from: https://github.com/pothosware/SoapySDR/wiki/PythonSupport
|
|
||||||
#
|
|
||||||
|
|
||||||
import SoapySDR
|
|
||||||
from SoapySDR import * #SOAPY_SDR_ constants
|
|
||||||
import numpy #use numpy for buffers
|
|
||||||
import sys
|
|
||||||
import struct
|
|
||||||
|
|
||||||
#enumerate devices
|
|
||||||
devices = [dict(device) for device in SoapySDR.Device.enumerate()]
|
|
||||||
|
|
||||||
if len(devices) == 0:
|
|
||||||
print('No SDR devices available.')
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
#create device instance
|
|
||||||
sdr = SoapySDR.Device(devices[0])
|
|
||||||
|
|
||||||
#apply settings
|
|
||||||
sdr.setSampleRate(SOAPY_SDR_RX, 0, 1e6)
|
|
||||||
sdr.setFrequency(SOAPY_SDR_RX, 0, 912.3e6)
|
|
||||||
|
|
||||||
#setup a stream (complex floats)
|
|
||||||
rxStream = sdr.setupStream(SOAPY_SDR_RX, SOAPY_SDR_CF32)
|
|
||||||
sdr.activateStream(rxStream) #start streaming
|
|
||||||
|
|
||||||
#create a re-usable buffer for rx samples
|
|
||||||
samples = 1000
|
|
||||||
buff = numpy.array([0]*samples*2, numpy.float32)
|
|
||||||
|
|
||||||
#receive some samples
|
|
||||||
for i in range(10):
|
|
||||||
sr = sdr.readStream(rxStream, [buff], samples)
|
|
||||||
|
|
||||||
sys.stdout.buffer.write(struct.pack('=%df' % len(buff), *buff))
|
|
||||||
|
|
||||||
#shutdown the stream
|
|
||||||
sdr.deactivateStream(rxStream) #stop streaming
|
|
||||||
sdr.closeStream(rxStream)
|
|
||||||
52
examples/example.py
Executable file
52
examples/example.py
Executable file
@ -0,0 +1,52 @@
|
|||||||
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
|
#
|
||||||
|
# Example script for interfacing with SDRPlay radio.
|
||||||
|
#
|
||||||
|
# Modified from: https://github.com/pothosware/SoapySDR/wiki/PythonSupport
|
||||||
|
#
|
||||||
|
|
||||||
|
import SoapySDR
|
||||||
|
from SoapySDR import * # SOAPY_SDR_ constants
|
||||||
|
import numpy as np
|
||||||
|
import sys
|
||||||
|
import struct
|
||||||
|
|
||||||
|
# enumerate devices
|
||||||
|
devices = [dict(device) for device in SoapySDR.Device.enumerate()]
|
||||||
|
|
||||||
|
for device in devices:
|
||||||
|
print(device)
|
||||||
|
|
||||||
|
if len(devices) == 0:
|
||||||
|
print("No SDR devices available.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# create device instance
|
||||||
|
sdr = SoapySDR.Device(devices[0])
|
||||||
|
|
||||||
|
# apply settings
|
||||||
|
sdr.setSampleRate(SOAPY_SDR_RX, 0, 1e6)
|
||||||
|
sdr.setFrequency(SOAPY_SDR_RX, 0, 912.3e6)
|
||||||
|
|
||||||
|
# setup a stream (complex floats)
|
||||||
|
rxStream = sdr.setupStream(SOAPY_SDR_RX, SOAPY_SDR_CF32)
|
||||||
|
sdr.activateStream(rxStream) # start streaming
|
||||||
|
|
||||||
|
# create a re-usable buffer for rx samples
|
||||||
|
samples = 1000
|
||||||
|
buff = np.array([0] * samples * 2, np.float32)
|
||||||
|
|
||||||
|
# receive some samples
|
||||||
|
for i in range(10):
|
||||||
|
sr = sdr.readStream(rxStream, [buff], samples)
|
||||||
|
|
||||||
|
print(
|
||||||
|
f"Samples: {sr.ret}, flags: {sr.flags}, timestamp {sr.timeNs}", file=sys.stderr
|
||||||
|
)
|
||||||
|
|
||||||
|
sys.stdout.buffer.write(struct.pack("=%df" % len(buff), *buff))
|
||||||
|
|
||||||
|
# shutdown the stream
|
||||||
|
sdr.deactivateStream(rxStream) # stop streaming
|
||||||
|
sdr.closeStream(rxStream)
|
||||||
Binary file not shown.
BIN
sdrplay_int16.iq
BIN
sdrplay_int16.iq
Binary file not shown.
Loading…
Reference in New Issue
Block a user