當前位置: 首頁>>代碼示例>>Python>>正文


Python RtlSdr.center_freq方法代碼示例

本文整理匯總了Python中rtlsdr.RtlSdr.center_freq方法的典型用法代碼示例。如果您正苦於以下問題:Python RtlSdr.center_freq方法的具體用法?Python RtlSdr.center_freq怎麽用?Python RtlSdr.center_freq使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rtlsdr.RtlSdr的用法示例。


在下文中一共展示了RtlSdr.center_freq方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import center_freq [as 別名]
 def run(self):
   
   # Read 128ms of data at a time (must be a multiple of a power of two)
   blkSize = SAMPLE_RATE_KHZ()*128;
   blockLoc = np.zeros(1,dtype=np.uint64);
   
   sdr = RtlSdr();
   # configure device
   sdr.sample_rate = SAMPLE_RATE_KHZ()*1e3  # Hz
   sdr.center_freq = 1575420000     # Hz
   sdr.gain = 29;
   sdrQueue.put((sdr,blockLoc,blkSize/SAMPLE_RATE_KHZ(),1));
   sdr.read_samples_async(sdrCallback, blkSize, context=sdrQueue);
開發者ID:dswiston,項目名稱:pyGpsReceiver,代碼行數:15,代碼來源:gps.py

示例2: get_sdr

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import center_freq [as 別名]
def get_sdr():
	sdr = RtlSdr()

	#configure device
	#sdr.sample_rate = 2.048e6 	#Hz
	#sdr.center_freq = 70e6		#Hz
	#sdr.freq_correction = 60	# PPM
	#sdr.gain = 'auto'
	sdr.sample_rate = 200000
	sdr.center_freq = 907 * 1000 * 1000
	sdr.freq_correction = 60	# PPM
	sdr.gain = 'auto'

	return sdr
開發者ID:rpasta42,項目名稱:electron-pysdr,代碼行數:16,代碼來源:py_stdcom.py

示例3: get_data

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import center_freq [as 別名]
def get_data(freq):
    sdr = RtlSdr()

    sdr.sample_rate = 2.048e6
    sdr.center_freq = int(decimal.Decimal(str(freq) + 'e6'))
    sdr.freq_correction = 60
    sdr.gain = 'auto'

    data = sdr.read_samples(512)

    if not data.any():
        app.abort(404, 'No data!')

    d = []
    for item in data:
        d.append(str(item))

    js = json.dumps(d)
    return js
開發者ID:JE6HBC,項目名稱:satnogs-software,代碼行數:21,代碼來源:simplesdr.py

示例4: storing_stream_with_windows

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import center_freq [as 別名]
def storing_stream_with_windows(l, device_number, folder, subfolders, center_frequency, samplerate, gain, nsamples, freq_correction,
                   user_hash):
    l.acquire()
    print(device_number, center_frequency, samplerate, gain, nsamples, freq_correction)
    # configure device
    sdr = RtlSdr(device_index=device_number)
    sdr.center_freq = center_frequency
    sdr.sample_rate = samplerate
    if freq_correction:
        sdr.freq_correction = freq_correction   # PPM
    sdr.gain = gain
    print('hello world')
    timestamp = time.mktime(time.gmtime())
    samples = sdr.read_bytes(nsamples*2)
    sdr.close()
    l.release()

    print("save")
    basename = "{hash}_{freq}_{time:0.0f}".format(hash=user_hash, freq=center_frequency, time=timestamp)
    filename = path.join(folder, subfolders[0], "tmp_" + basename)
    # np.savez_compressed(filename, samples) # storing by numpy and copressing it
    '''np.save(filename, samples)
    os.rename(filename + ".npy",
              path.join(folder, subfolders[0], basename + ".npy"))'''

    f = open(filename, 'wb')
    f.write(samples)
    f.close()
    os.rename(filename,
              path.join(folder, subfolders[0], basename + ".dat"))

    del samples

    filename = path.join(folder, subfolders[1], basename + ".npy")
    sdrmeta(filename, device_number, folder, subfolders, center_frequency,
            samplerate, gain, nsamples, freq_correction, user_hash)

    return filename
開發者ID:aerospaceresearch,項目名稱:dgsn-node-io-radio,代碼行數:40,代碼來源:record-radio.py

示例5: RtlSdr

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import center_freq [as 別名]
from radio_params import *
from radio_transmit import *

record_len = 75

## configure SDR
sdr = RtlSdr()

freq_offset = 93.2e3

sample_rate = 240e3
center_freq = 443.592e6 - freq_offset
#center_freq = 145.442e6 #- freq_offset

sdr.sample_rate = sample_rate  
sdr.center_freq = center_freq   
sdr.gain = 10

## get samples
samples = []

def callback(ss, obj):
    samples.append(ss)
    #obj.cancel_read_async()

print('Ready to record!')
raw_input("Press Enter to record...")
    
print('recording...')
N_samples = sample_rate*0.5 # approximately seconds
sdr.read_samples_async(limit_time(record_len)(callback), N_samples)   # get samples
開發者ID:lambdaloop,項目名稱:radio-images,代碼行數:33,代碼來源:receive_image.py

示例6: int

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import center_freq [as 別名]
		config.sample_num = int(sys.argv[i+1])
	elif (arg == "-c"):
		config.center_freq = int(sys.argv[i+1])
	elif (arg == "-r"):
		config.sample_rate = int(sys.argv[i+1])

#init RTLSDR and if no then go out
try:
	sdr = RtlSdr()
except IOError:
	print "Probably RTLSDR device not attached"
	sys.exit(0)

# configure device
sdr.sample_rate = config.sample_rate  # Hz
sdr.center_freq = config.center_freq     # Hz
sdr.freq_correction = 60   # PPM
sdr.gain = 'auto'


samples = sdr.read_samples( config.sample_num )
if config.matlab_flag == False:
	print( samples )
else:
	print "samples = [",
	for s in samples:
		if s.imag < 0.0:
			print "%s%si "%(str(s.real), str(s.imag)),
		else:
			print "%s+%s "%(str(s.real), str(s.imag)),
	print "];"
開發者ID:antiface,項目名稱:sdrdsp-protos,代碼行數:33,代碼來源:get_data.py

示例7: RtlSdr

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import center_freq [as 別名]
from rtlsdr import RtlSdr

sdr = RtlSdr()

# configure device
sdr.sample_rate = 240e3  # Hz
sdr.center_freq = 101.7e6     # Hz
sdr.freq_correction = 0   # PPM
sdr.gain = 'auto'

print(sdr.read_samples(512))
開發者ID:TuringTW,項目名稱:SoftwareRadar,代碼行數:13,代碼來源:go.py

示例8: exit

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import center_freq [as 別名]
                        bitstr += "0"
                    else:
                        bitstr += "1"
                        if bitCount < 6:
                            scancode += 1 << bitCount
                    bitCount += 1
                    bitValue = 0
                    if bitCount > 10:
                        bitCount = 0
                        state = 0  # fin demod
        except:
            exit(0)


if __name__ == "__main__":
    q = Queue()
    p = Process(target=AsyncWelchProcess, args=(q,))
    p.start()

    def on_sample(buf, queue):
        queue.put(list(buf))

    from rtlsdr import RtlSdr

    sdr = RtlSdr()
    # configure device
    sdr.sample_rate = SAMPLE_RATE  # sample rate
    sdr.center_freq = FREQ
    sdr.gain = "auto"
    sdr.read_samples_async(on_sample, 2048, context=q)
開發者ID:Groundworkstech,項目名稱:submicron,代碼行數:32,代碼來源:capture.py

示例9: return

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import center_freq [as 別名]
  
  return (num,den);


fmDemod = FMDemod();
fileRead = FileReader();
audioPlay = AudioPlay();

dataQueue = Queue.Queue([1]);
audioQueue = Queue.Queue([1]);

sdr = RtlSdr();

# configure device
sdr.sample_rate = 250e3;  # Hz
numSampsRead = 1024*600;
freq = raw_input('Choose a station frequency: ');

try:
  freq = float(freq);
  sdr.center_freq = freq;
  sdr.gain = 'auto';
  #fileRead.start();
  fmDemod.start();
  audioPlay.start();
  sdr.read_samples_async(sdrCallback, numSampsRead);    
    
except ValueError:
  print("Invalid number");
    
開發者ID:dswiston,項目名稱:pyFmRadio,代碼行數:31,代碼來源:pyFmRadio.py

示例10: output

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import center_freq [as 別名]
#echos rtlsdr read_samples output (without lines starting with hyphen) to console and to ~/finaldata.txt
import os
from rtlsdr import RtlSdr

os.chdir(os.path.expanduser("~/"))
sdr = RtlSdr()

sdr.sample_rate = 2.048e6 #Hz
sdr.center_freq = 70e6 # Hz
sdr.freq_correction = 60 # PPM
sdr.gain = 'auto'

sdroutput = str(sdr.read_samples(512))
savefile = open('finaldata.txt', 'w')
sdr1 = sdroutput.translate(None, '[]').split()
sdr2 = sdr1
finaldata = ''
for line in sdr2:
    if not "-" in line:
        finaldata+=line+"\n"

print finaldata
savefile.write(finaldata)
savefile.close()
開發者ID:python-sdr,項目名稱:rtlsdr,代碼行數:26,代碼來源:hyphens.py

示例11: str

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import center_freq [as 別名]
#print "Stepsize = " + str(stepsize*10)
print "Steps = " + str(steps)
X = np.linspace(freq_int*10, freq_int*10 + int(bw), samples)
print args.output_path + '--' + csvfile + '.csv'
sys.stdout.flush()
for x in range(0, 1000000):
	time.sleep(5)
	cent_freq = (int(low_freq) + (x%steps))
	# configure device
	sample_rate = samp_rate
#	sdr.freq_correction = 82
	#freq = 1379.913e6
#	freq = [freq_int*10)+stepsize*x*10 if freq_int*10<(freq_int*10+int(bw)) else cent_freq]
	print 'low_freq,',low_freq
	sdr.sample_rate = sample_rate  # Hz
	sdr.center_freq = cent_freq     # Hz
	sdr.gain = 'auto'
	sampnumber = 8192*2*2*2*2*2*2
	samples2 = sdr.read_samples(sampnumber)
	#ser.write("\x8f\x78" + freq_str + stepsize_str + samples_str)
#	print freq
        time.sleep(1)
	
#print "please wait..."
#print s
       # byte_list = map(ord,t)
	
	bdrate = 2000
	phasesarr=[]
	phases=np.arctan2((samples2.imag),(samples2.real))
	codeword="001001011101010111000000110011101000100110010000111101101100100101000110000110111111011110011100110110100010101000111111001100010111011001101111000010010011011010111001111001000000100001100011"
開發者ID:DoYouKnow,項目名稱:TURBOSCAN,代碼行數:33,代碼來源:fullscan.py

示例12: acquireSamplesAsync

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import center_freq [as 別名]
def acquireSamplesAsync(fs, fc, t_total, chunk_size=1024, num_SDRs=3, gain=36):
    """
    Asynchronously acquire samples and save them.
    """

    assert type(t_total) == int, "Time must be an integer."
    N_samples = 1024000*t_total #1024000 256000 3.2e6
    SDRs = []

    # Initialize the SDRs
    for i in xrange(num_SDRs):
        sdr_i = RtlSdr(device_index=i)
        sdr_i.sample_rate = fs
        sdr_i.center_freq = fc
        sdr_i.gain = gain
        SDRs.append(sdr_i)

    # Setup the output queues
    output_queues = [Queue() for _ in xrange(num_SDRs)]

    rec_thrds = []

    # Create the thread objects for acquisition
    for i, sdr_i in enumerate(SDRs):
        y = output_queues[i]
        sdr_rec = threading.Thread(target=recordSamples, \
                          args=(sdr_i, i, N_samples, y, N_samples))
        rec_thrds.append(sdr_rec)

    # Start the threads
    for rec_thread in rec_thrds:
        rec_thread.start()


    # Wait until threads are done
    while any([thrd.is_alive() for thrd in rec_thrds]):
        time.sleep(1)
        """
        for i, size in enumerate(last_size):
            curr_size = output_queues[i].qsize()
            if not done_arr[i] and size == curr_size:
                #rec_thrds[i].terminate()
                done_arr[i] = True
            else:
                last_size[i] = curr_size
        """

    # For DEBUG
    samples = []
    for i, q in enumerate(output_queues):
        print "Printing Queue %d" % i
        print "\t- Queue size: %d" % q.qsize()
        samples.append([])
        while not q.empty():
            print q.qsize()
            samples[i] += list(q.get())

        print "Done"

    np.save('demo.npy',samples)
    for i in range(num_SDRs-1):
        assert len(samples[i]) == len(samples[i+1])

    return samples
開發者ID:jtcramer,項目名稱:phasedarraylocalization,代碼行數:66,代碼來源:acquire.py

示例13: RtlSdr

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import center_freq [as 別名]
import numpy as np
import time
from rtlsdr import RtlSdr

sdr = RtlSdr()

#config
sdr.samle_rate = 2.048e6
sdr.center_freq = 433888000
#sdr.freq_correction = 60
sdr.gain = 'auto'

#print(sdr.read_samples(512))

burst = 0
burst_time = 0
overall_avg = 20

while True:
	samples = sdr.read_samples(512*2);
	#run an FFT and take absolute value to get freq magnitudes
	freqs = np.absolute(np.fft.fft(samples))
	#ignore the mean/DC values at ends
	freqs = freqs[1:-1]
	#Shift FFT result positions to put center frequency in center
	freqs = np.fft.fftshift(freqs)
	#convert to decibels
	freqs = 20.0*np.log10(freqs)

	mean = np.mean(freqs)
	min = np.min(freqs)
開發者ID:mfairchild365,項目名稱:Skylink-GM-434RTL,代碼行數:33,代碼來源:door.py

示例14: int

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import center_freq [as 別名]
     if hopCount == 0:
	hopCount = 1

     sampleCount = options.dwell_time*options.samp_rate
	
     p = int(math.log(sampleCount,2) + 1)
	
     sampleCount = pow(2,p)
	
     print "SampleCount ", sampleCount
   
     sdr = RtlSdr()
     sdr.sample_rate = options.samp_rate
     sdr.gain = 4
     sdr.freq_correction = 60

     while True:
         for i in range(0,int(hopCount) - 1):
	     sdr.center_freq = startHz + i*options.samp_rate + offset
	     samples = sdr.read_samples(sampleCount)
	     energy = numpy.linalg.norm(samples)/sampleCount
	     print "Center Freq ", (startHz + i*options.samp_rate + offset)/1e6 , " Mhz", " Energy ", energy


     
    
     


開發者ID:usnistgov,項目名稱:rtlsdr-tv-whitespace-monitor,代碼行數:24,代碼來源:sense-whitespace.py

示例15: main

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import center_freq [as 別名]
def main():
    print("you are using", platform.system(), platform.release(), os.name)

    # creating the central shared dgsn-node-data for all programs on the nodes
    #######################################
    pathname = os.path.abspath(os.path.dirname(sys.argv[0]))
    pathname_all = ""
    for i in range(len(pathname.split(path_separator))-2): # creating the folders two folder levels above
        pathname_all = pathname_all + pathname.split(path_separator)[i] + path_separator
    pathname_save = pathname_all + "dgsn-node-data"
    pathname_config = pathname_all + "dgsn-hub-ops"

    # creating the dump folder for files and the needed data folders
    #######################################
    if not os.path.exists(pathname_save):
        os.makedirs(pathname_save)

    folder = pathname_save + path_separator + "rec"
    subfolders = ["iq", "sdr", "gapped", "coded", "monitor"]
    if not os.path.exists(folder):
        os.makedirs(folder)

    if os.path.exists(folder):
        for i in range(len(subfolders)):
            if not os.path.exists(folder + path_separator + subfolders[i]):
                os.makedirs(folder + path_separator + subfolders[i])

    if not os.path.exists(pathname_config):
        os.makedirs(pathname_config)

    pathname_config = pathname_config + path_separator + "io-radio"

    if not os.path.exists(pathname_config):
        os.makedirs(pathname_config)

    # setting the rtlsdr before the gain finding
    #####################################

    # getting one file to each node very simple via github, or via a local file copy
    data = loading_config_file(pathname_config)

    # getting the specific settings for the node itself. perhaps it cannot be as fast as others
    with open(pathname + path_separator +'node-config.json') as data_file:
        data_node = json.load(data_file)

    device_number = data["device_number"]
    center_frequency = data["center_frequency"]
    samplerate = data["samplerate"]

    # this will be necessary in case a full fledged pc is a node or in case a micro pc is used with less RAM
    secondsofrecording = min(data["secondsofrecording"], data_node["secondsofrecording_maximum"])
    print("record seconds commanded", data["secondsofrecording"], "record seconds maximum",
          data_node["secondsofrecording_maximum"], "and it is", secondsofrecording)

    nsamples = secondsofrecording * samplerate
    freq_correction = data["freq_correction"]
    user_hash = get_groundstationid()

    dt = datetime.datetime(data["recording_start"]["year"], data["recording_start"]["month"], data["recording_start"]["day"],
                           data["recording_start"]["hour"], data["recording_start"]["minute"], data["recording_start"]["second"])
    recording_start = time.mktime(dt.timetuple())

    dt = datetime.datetime(data["recording_end"]["year"], data["recording_end"]["month"], data["recording_end"]["day"],
                           data["recording_end"]["hour"], data["recording_end"]["minute"], data["recording_end"]["second"])
    recording_stop = time.mktime(dt.timetuple())

    # getting the data for calibration
    calibration_start = data["calibration_start"]
    gain_start = data["gain_start"]
    gain_end = data["gain_end"]
    gain_step = data["gain_step"]
    signal_threshold = data["signal_threshold"]
    print("gg", gain_start, gain_end)

    ##################################
    print("starting the fun...")

    if platform.system() == "Windows":
        print("detecting a windows")
        ##############
        device_count = librtlsdr.rtlsdr_get_device_count()
        print("number of rtl-sdr devices:", device_count)

        if device_count > 0:
            lock = Lock()
            jobs = []
            gain = 0
            calibration_finished = 0 # 1 means calibration is done

            while time.mktime(time.gmtime()) <= recording_start or calibration_finished == 0:
                # waiting for the time to be right :)
                time.sleep(10)
                print("still to wait", recording_start - time.mktime(time.gmtime()), "to record and",
                  recording_start - time.mktime(time.gmtime())- calibration_start, "to calibration")

                if time.mktime(time.gmtime()) > recording_start - calibration_start and calibration_finished == 0:
                    sdr = RtlSdr(device_index=device_number)
                    sdr.center_freq = center_frequency
                    sdr.sample_rate = samplerate
                    # sdr.freq_correction = 1   # PPM
#.........這裏部分代碼省略.........
開發者ID:aerospaceresearch,項目名稱:dgsn-node-io-radio,代碼行數:103,代碼來源:record-radio.py


注:本文中的rtlsdr.RtlSdr.center_freq方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。