示例#1
0
def main(ic):
    """
    Start up everything and run main loop from here.
    """
    # setup a logger
    log = iono_logger.logger("rx-")

    s = ic.s

    # register signals to be caught
    signal.signal(signal.SIGUSR1, orderlyExit)

    log.log("Sweep freqs:")
    log.log(str(s.freqs))
    log.log("Sweep length %1.2f s Freq step %1.2f" %
            (s.sweep_len_s, s.freq_dur))

    # Configuring USRP
    sample_rate = ic.sample_rate

    # number of samples per freq
    N = int(sample_rate * s.freq_dur)

    # configure usrp
    usrp = uhd.usrp.MultiUSRP("addr=%s,recv_buff_size=500000000" %
                              (ic.rx_addr))
    usrp.set_rx_rate(sample_rate)
    subdev_spec = uhd.usrp.SubdevSpec(ic.rx_subdev)
    usrp.set_rx_subdev_spec(subdev_spec)

    # Synchronizing clock
    gl.sync_clock(usrp, log, min_sync_time=ic.min_gps_lock_time)

    # figure out when to start the cycle.
    t_now = usrp.get_time_now().get_real_secs()
    t_now_dt = datetime.fromtimestamp(t_now)
    # add 5 secs for setup time
    t0 = np.uint64(
        np.floor((t_now + 5.0) / (s.sweep_len_s)) * s.sweep_len_s +
        s.sweep_len_s)
    t0_dt = datetime.fromtimestamp(t0)
    print("starting next sweep at %1.2f (%s) in %1.2f s, time now %1.2f (%s)" %
          (t0, t0_dt.strftime("%FT%T.%f")[:-3], t0 - t_now, t_now,
           t_now_dt.strftime("%FT%T.%f")[:-3]))

    # start with initial frequency
    tune_req = uhd.libpyuhd.types.tune_request(s.freq(0))
    usrp.set_rx_freq(tune_req)

    # start reading data
    housekeeping_thread = threading.Thread(target=housekeeping,
                                           args=(usrp, log, ic))
    housekeeping_thread.daemon = True
    housekeeping_thread.start()

    # infinitely loop on receive
    receive_continuous(usrp, t0, t_now, ic, log)
示例#2
0
 def __init__(self):
     self.kill_now = False
     signal.signal(signal.SIGINT, self.exit_gracefully)
     signal.signal(signal.SIGTERM, self.exit_gracefully)
示例#3
0
import multiprocessing, errno
from multiprocessing import Process, JoinableQueue, Queue
import sys, os, json
import argparse
import numpy as np
import scipy
import scipy.signal
import tensorflow as tf
import time
import signal
from collections import deque
sys.path.append('./gym')
import gym

signal.signal(signal.SIGINT, signal.default_int_handler)

# PROGRAM PARAMETERS
ENV_NAME_DEFAULT = 'Grasper3d-v0'
SCOPE_DEFAULT = 'grasper'
IS_LOAD_DEFAULT = False
N_PROCESSES_DEFAULT = multiprocessing.cpu_count()
if sys.platform == "darwin":  # we want physical cores not logical
    N_PROCESSES_DEFAULT /= 2
IS_MONITOR_DEFAULT = True
IS_TRAIN_DEFAULT = True
MONITOR_FREQ_DEFAULT = 50

# SAVING & STUFF
LOG_DIR_DEFAULT = './logs'
CHECKPOINT_DIR_DEFAULT = './checkpoints'
CHECKPOINT_FREQ_DEFAULT = 50
示例#4
0
 def __init__(self):
     self.kill_now = False
     signal.signal(signal.SIGINT, self.exit_gracefully)
     signal.signal(signal.SIGTERM, self.exit_gracefully)
示例#5
0
import signal
import sys


def signal_handler(signal, frame):
    print('You pressed Ctrl+C!')
    s.close()
    stream.stop_stream()
    stream.close()

    # close PyAudio (5)
    p.terminate()
    sys.exit(0)


signal.signal(signal.SIGINT, signal_handler)
'''
axcolor = 'lightgoldenrodyellow'
axfreq = plt.axes([0.25, 0.1, 0.65, 0.03], axisbg=axcolor)


sfreq = Slider(axfreq, 'Freq', -5.e5, -3.e5, valinit=-4.e5)
def update(val):
    offset = sfreq.val
sfreq.on_changed(update)
plt.ion()
plt.show()
'''

from Tkinter import *
示例#6
0
from gnuradio import gr
from gnuradio import qtgui
from gnuradio.eng_option import eng_option
from gnuradio.filter import firdes
from optparse import OptionParser
import sip
import sys

import pyqtgraph as pg

#from blocks import BEServer, Threshold
import numpy as np
import scipy.signal

import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)

cnt = 0

import threading, time
import math


class InputDict(object):
    pass


class Input(object):
    """Attribute type for describing signal inputs of Blocks"""

    # A counter used to find out the order of declaration
示例#7
0
            # file exists, return true
            os.remove("kill_cmd.txt")
            return True
        return False
    except:
        return False


# MAC/LINUX
# ble runloop cannot handle signal interrupts
def receive_interrupt(signum, stack):
    print("interrupt")


# if signals are supported, then fork a child process and use its pid
if utils.does_support_signals():
    fork_pid = os.fork()

    if fork_pid == 0:  # case: child process, run BLE on thread here
        # Initialize the BLE system.  MUST be called before other BLE calls!
        ble = Adafruit_BluefruitLE.get_provider()
        ble.initialize()
        # Start the mainloop to process BLE events, and run the provided function in
        # a background thread.  When the provided main function stops running, returns
        # an integer status code, or throws an error the program will exit.
        print("Starting main runloop")
        ble.run_mainloop_with(ble_main)

    else:  # parent case: receive signals and notify child through a secondary command file
        signal.signal(signal.SIGINT, receive_interrupt)
 def __enter__(self):
     signal.signal(signal.SIGALRM, self.handle_timeout)
     signal.alarm(self.seconds)
示例#9
0
# %%

b, a = fdls.fdls(data.frequency, data.amplitude, data.phase, fs=1000)

w, h = scipy.signal.freqz(b, a)

# %%
plt.figure(2)
plt.title('Continuous digital filter frequency response')

plt.plot(w, h)

plt.ylabel('Amplitude')
plt.xlabel('Frequency (Hz)')
plt.grid()


# %%
# Must register singal handler before showing plot, enters TKAgg event loop
def handler(signum, frame):
    print('Quitting')
    try:
        plt.close()
    finally:
        sys.exit(0)


signal.signal(signal.SIGINT, handler)

plt.show()
示例#10
0
from gnuradio import gr
from gnuradio import qtgui
from gnuradio.eng_option import eng_option
from gnuradio.filter import firdes
from optparse import OptionParser
import sip
import sys

import pyqtgraph as pg

from blocks import BEServer, Threshold
import numpy as np
import scipy.signal

import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)

cnt = 0

import threading, time
import math

class InputDict(object):
    pass

class Input(object):
    """Attribute type for describing signal inputs of Blocks"""

    # A counter used to find out the order of declaration 
    order = 0