Advertisement
Guest User

Untitled

a guest
May 6th, 2019
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. from rtlsdr import RtlSdr
  2. import struct
  3. import numpy as np
  4.  
  5. sdr = RtlSdr()
  6.  
  7. # configure device
  8. sdr.sample_rate = 2.048e6 # Hz
  9. sdr.center_freq = 100e6 # Hz
  10. sdr.freq_correction = 60 # PPM
  11. sdr.gain = 'auto'
  12.  
  13. def get_samples():
  14. bytes = sdr.read_bytes(1024)
  15. samples = [(x - 127.4) * (1/128.0) for x in bytes]
  16. num_samples = len(samples)
  17. return struct.pack('%sf' % num_samples, *samples)
  18.  
  19. output_file = open('rec.bin', 'wb')
  20.  
  21. while True:
  22. try:
  23. output_file.write(get_samples())
  24. except KeyboardInterrupt:
  25. output_file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement