Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from rtlsdr import RtlSdr
- import struct
- import numpy as np
- sdr = RtlSdr()
- # configure device
- sdr.sample_rate = 2.048e6 # Hz
- sdr.center_freq = 100e6 # Hz
- sdr.freq_correction = 60 # PPM
- sdr.gain = 'auto'
- def get_samples():
- bytes = sdr.read_bytes(1024)
- samples = [(x - 127.4) * (1/128.0) for x in bytes]
- num_samples = len(samples)
- return struct.pack('%sf' % num_samples, *samples)
- output_file = open('rec.bin', 'wb')
- while True:
- try:
- output_file.write(get_samples())
- except KeyboardInterrupt:
- output_file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement