Commit 8805b304 authored by Jenda's avatar Jenda

allow pipe scanner output

parent 2e715051
......@@ -300,7 +300,7 @@ class client():
def spawn_mode(self, cmd):
""" Spawn a process cmd, spawn feeder_thr for it, return reference to queue and thread. """
process = subprocess.Popen([cmd], stdin=subprocess.PIPE, shell=True)
process = subprocess.Popen([cmd], stdin=subprocess.PIPE, shell=True, bufsize=-1)
que = Queue.Queue()
t = threading.Thread(target=self.feeder_thr, args=(que, process), name="feeder_thr for %s"%cmd)
t.daemon = True
......
......@@ -11,13 +11,14 @@ import math
import numpy as np
import xlater
import struct
import subprocess
from datetime import datetime
from libutil import Struct, safe_cast
from gnuradio.filter import firdes
def channelhelper():
ChannelHelperT = Struct("channelhelper", "rotator decim rate file taps carry rotpos firpos cylen")
ChannelHelperT = Struct("channelhelper", "rotator decim rate file taps carry rotpos firpos cylen fd_r")
return ChannelHelperT()
COMPLEX64 = 8
......@@ -75,7 +76,7 @@ class scanner():
self.sdrflush()
peaks = []
for channel in cronframe.channels:
peaks.append((channel.freq-cronframe.freq, channel.bw))
peaks.append((channel.freq-cronframe.freq, channel.bw, channel))
self.do_record(peaks, cronframe.cronlen, cronframe.stickactivity, 1, channel.freq, cronframe.floor, None)
......@@ -114,7 +115,6 @@ class scanner():
ch.decim = math.ceil(self.conf.rate/w)
ch.rate = self.conf.rate/ch.decim
ch.file = os.open(self.getfn(f+center, ch.rate) + ".cfile", os.O_WRONLY|os.O_CREAT)
ch.rotator = -float(f)/self.conf.rate * 2*math.pi
ch.rotpos = np.zeros(2, dtype=np.float32)
ch.rotpos[0] = 1 # start with unit vector
......@@ -123,7 +123,15 @@ class scanner():
ch.firpos = np.zeros(1, dtype=np.int32)
ch.cylen = len(ch.taps)
ch.carry = '\0' * ch.cylen
self.l.l("Recording %s"%ch.file, "INFO")
if len(peak) >= 2 and peak[2].pipe is not None:
(ch.fd_r, ch.file) = os.pipe()
subprocess.Popen([peak[2].pipe], shell=True, stdin=ch.fd_r, bufsize=-1)
self.l.l("Recording %i (PIPE)"%f, "INFO")
else:
ch.file = os.open(self.getfn(f+center, ch.rate) + ".cfile", os.O_WRONLY|os.O_CREAT)
self.l.l("Recording %s"%ch.file, "INFO")
helpers.append(ch)
while True:
......@@ -154,6 +162,8 @@ class scanner():
for ch in helpers:
os.close(ch.file)
if ch.fd_r:
os.close(ch.fd_r)
def check_activity(self, acc, peak, q):
floor = sorted(acc)[int(q * self.conf.fftw)]
......
......@@ -2,9 +2,9 @@
freq=100000
floor=0.2
sql=0.3
cron=58 21 * * *
cron=* 22 * * *
cronlen=60
randscan=yes
randscan=no
stickactivity=True
[Channel1]
......
......@@ -80,11 +80,6 @@ class ConfReader():
except:
stick = self.stick
try:
pipe = rc.get(MAINSECTION, 'pipe')
except:
pipe = None
if "freqstart" in rc.options(MAINSECTION): # range randscan
freqstart = rc.getint(MAINSECTION, "freqstart")*1000 + step/2
freqstop = rc.getint(MAINSECTION, "freqstop")*1000 - step/2
......@@ -97,7 +92,6 @@ class ConfReader():
frm.floor = floor
frm.stickactivity = stickactivity
frm.stick = stick
frm.pipe = pipe
frm.sql = sql
frm.gain = self.gain
......@@ -109,10 +103,9 @@ class ConfReader():
frm = cronframe()
frm.freq = rc.getint(MAINSECTION, "freq")*1000
frm.floor = "floor"
frm.floor = self.floor
frm.stickactivity = stickactivity
frm.stick = stick
frm.pipe = pipe
frm.sql = sql
frm.gain = self.gain
frm.cron = rc.get(MAINSECTION, "cron")
......@@ -133,7 +126,6 @@ class ConfReader():
frm.floor = floor
frm.stickactivity = stickactivity
frm.stick = stick
frm.pipe = pipe
frm.sql = sql
frm.gain = self.gain
......@@ -159,6 +151,11 @@ class ConfReader():
except:
ch.cont = 0
try:
ch.pipe = rc.get(ssect, 'pipe')
except:
ch.pipe = None
channels.append(ch)
return channels
......
......@@ -35,7 +35,7 @@ int xdump(char * _buf, size_t buflen, char * _carry, size_t carrylen, char * _ta
int32_t i;
int outsample = 0;
FILE * of = fdopen(fd, "a");
FILE * of = fdopen(fd, "w");
if(of == NULL) {
perror("fdopen");
fprintf(stderr, "Cannot open fd %i for writing\n", fd);
......
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