File: sdr_control.py

package info (click to toggle)
quisk 4.2.32-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,064 kB
  • sloc: python: 22,219; ansic: 19,027; makefile: 38; sh: 2
file content (36 lines) | stat: -rwxr-xr-x 1,166 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

import os,sys
os.environ['PATH'] = os.path.dirname(__file__) + ';' + os.environ['PATH']

import afedrinet
import afedrinet.afedri

class Control:
  def __init__(self, sdr_address="192.168.0.8", sdr_port=50000):
        self.hw = afedrinet.afedri.afedri(sdr_address, sdr_port)
        if self.hw.s is None:	# Failure to find the hardware
                self.hw = None
  def OpenHW(self):
        if not self.hw: return
        data  = self.hw.get_sdr_name()
        print (data[4:])
        self.hw.start_capture()
  def CloseHW(self):
        if not self.hw: return
        self.hw.stop_capture()
        self.hw.close                     # Close the socket when done
  def SetHWLO(self, vfo):
        if not self.hw: return
        self.hw.set_center_freq(vfo)
  def SetHWSR(self, sample_rate):
        if not self.hw: return
        self.hw.set_samp_rate(sample_rate)
        print ("Sample Rate %i" % sample_rate)
  def SetAttenuator(self, indx):
        if not self.hw: return
        self.hw.set_gain_indx(indx)