pyhackrf 发布2 赶紧升级吧 别用本人修改的了

 接收:

import pyhackrf2 as pyhackrf
import numpy as np

hackrf = pyhackrf.HackRF()
hackrf.sample_rate = 10e6
hackrf.center_freq = 91.4e6
hackrf.lna_gain = 40
hackrf.vga_gain = 62
hackrf.filter_bandwidth = 1000000

samples = hackrf.read_samples(40e6)

with open("1.data","wb") as fd:
    fd.write(pyhackrf.iq2bytes(samples))

发送大型数据:

import pyhackrf2 as pyhackrf
import numpy as np 
import time



hackrf = pyhackrf.HackRF()
hackrf.sample_rate = 10e6
hackrf.center_freq = 91.4e6
hackrf.lna_gain = 40
hackrf.txvga_gain = 62
hackrf.filter_bandwidth = 1000000

with open("1.data","rb") as fd:
    raw = bytearray(fd.read())

size = len(np.array(raw))
print(size)



n = 0
n1 = 0
n2 = 1000000

while n < (size / 1000000):
    hackrf.buffer = bytearray(raw[n1:n2])
    n1 += 1000000
    n2 += 1000000
    n += 1
    hackrf.start_tx()
    hackrf.stop_tx()
print(n1)

你可能感兴趣的:(linux,学习,numpy,python)