Commit fb35c142 authored by Jenda's avatar Jenda

updated example utilities

parent a2996a35
......@@ -13,3 +13,4 @@ server/server
client/c2s_pb2.py
server/c2s.pb-c.c
server/c2s.pb-c.h
scanner/xlater.py
......@@ -3,19 +3,24 @@
import libclient
import time
import math
from gnuradio.filter import firdes
# Create client object
cl = libclient.client()
rid = None
wid = None
# This gets called every time xlaters dictionary is changed
def xlater_cb():
global rid, wid
xls = cl.get_xlaters()
# go through the dictionary and look for our xlater
for w in xls:
r = xls[w].rid
if r == rid:
# if found, put the server-assigned ID to wid
wid = w
cl.set_xlater_callback(xlater_cb)
......@@ -23,16 +28,28 @@ cl.set_xlater_callback(xlater_cb)
cl.connect("localhost", 4444)
cl.set_auto_enable_xlater(True)
rid = cl.create_xlater(0.92, 43, firdes.low_pass(1, 2048000, 20000, 5000, firdes.WIN_HAMMING), "./modes/mfm.py", -1)
# compute rotator for -300 kHz
# a more portable implementation would register info_callback and use the server-provided samplerate
rotate = 300000.0/2048000 * 2*math.pi
# this is coarse too, kukuruku-gui uses fractional resampling
decim = 2048000/48000
# create the xlater, the temporary remote ID gets stored in rid
rid = cl.create_xlater(rotate, decim, firdes.low_pass(1, 2048000, 20000, 10000, firdes.WIN_HAMMING), "./modes/mfm.py", -1)
print "Created xlater, reference %i"%rid
time.sleep(5)
# wait for 10 s and if we have the server-assigned ID, retune to some other frequency
time.sleep(10)
if wid is not None:
print("retune")
cl.modify_xlater(wid, 2.15, firdes.low_pass(1, 2048000, 20000, 5000, firdes.WIN_HAMMING))
time.sleep(5)
print("destroy")
cl.disable_xlater(wid)
cl.destroy_xlater(wid)
rotate = 700000.0/2048000 * 2*math.pi
cl.modify_xlater(wid, rotate, None)
time.sleep(10)
# and kill the whole chain
print("destroy")
cl.disable_xlater(wid)
cl.destroy_xlater(wid)
cl.disconnect()
# The colormap generated by colormap.c
colormap = [(0, 0, 0),
(0, 0, 2),
(0, 0, 3),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment