Пример #1
0
 def __init__(self, uri=PLUTO_ID):
     # access to internal devices
     try:
         self.ctx = iio.Context(uri)
     except OSError:
         self.ctx = None
         print('exception: no iio device context found at', uri)
         return
     logging.debug('found context for pluto device')
     self.name = 'plutosdr'
     self.phy = self.ctx.find_device('ad9361-phy')
     # individual TRx controls
     self.phy_rx = self.phy.find_channel('voltage0', is_output=False)
     self.phy_tx = self.phy.find_channel('voltage0', is_output=True)
     # access to data channels for Rx
     self.adc = self.ctx.find_device('cf-ad9361-lpc')
     # access to data channels for Tx
     self.dac = self.ctx.find_device('cf-ad9361-dds-core-lpc')
     self.tx_channels = [self.dac.find_channel('voltage0', True)]
     self.tx_channels.append(self.dac.find_channel('voltage1', True))
     # also access to the internal 2 tone generator
     self.dds = pluto_dds.Dds(self.dac)
     #  tx buffer, created in writeTx and retained for continuous output
     self._tx_buff = None
     self.tx_state = self.TX_OFF
Пример #2
0
 def testSetAmplitude(self):
     """confirm amplitude values read/write and amp <= 0 dB"""
     dds = pluto_dds.Dds(self.dev)
     dds.setAmplitude()
     self.assertEqual(dds.t1.amplitude, 0,
                      'no arguments turns amplitude 1 off')
     self.assertEqual(dds.t2.amplitude, 0,
                      'no arguments turns amplitude 2 off')
     with self.assertRaises(ValueError, msg='values set in -dB '):
         dds.setAmplitude(10)
     dds.setAmplitude(-10)  # this is in dB
     npt.assert_almost_equal(
         dds.t1.amplitude,
         0.1,
         decimal=3,
         err_msg='first arguments turn sets f1 amplitude')
     self.assertEqual(dds.t2.amplitude, 0,
                      'no arguments turn amplitude 2 off')
     self.assertFalse(dds.isOff(), 'only 1 tone indicates on')
     dds.setAmplitude(-13, -13)
     npt.assert_almost_equal(dds.t1.amplitude,
                             0.05,
                             decimal=3,
                             err_msg='first arguments sets f1 amplitude')
     npt.assert_almost_equal(dds.t2.amplitude,
                             0.05,
                             decimal=3,
                             err_msg='second arguments sets f2 amplitude')
Пример #3
0
 def testSetPhase(self):
     """confirm the relative I/Q phases for +/- frequencies"""
     dds = pluto_dds.Dds(self.dev)
     tone = pluto_dds.DdsTone(self.dev, 'F1')
     tone.frequency = 1
     tone.phase = 180  # set phase mid way
     i_phase = tone.getPhase()
     q_phase = tone.getPhase('Q')
Пример #4
0
 def testDdsCreate(self):
     """create a Dds instance"""
     self.assertIsInstance(self.dev, iio.Device, 'ok')
     dds = pluto_dds.Dds(self.dev)
     self.assertIsInstance(dds.t1, pluto_dds.DdsTone,
                           'Dds Tone1 instance created')
     self.assertIsInstance(dds.t2, pluto_dds.DdsTone,
                           'Dds Tone2 instance created')
     self.assertTrue(dds.isOff(), "initial state is both off")
Пример #5
0
 def testSetFrequency(self):
     """confirm read and write to properties"""
     dds = pluto_dds.Dds(self.dev)
     fs = dds.getSamplingFreq()  # test tones must be within +/- hald Fs
     dds.setFrequency(fs / 4)
     npt.assert_almost_equal(dds.t1.frequency,
                             fs / 4,
                             decimal=3,
                             err_msg='set f1 frequency')
     dds.setFrequency(fs / 4, -fs / 8)
     npt.assert_almost_equal(dds.t1.frequency,
                             fs / 4,
                             decimal=3,
                             err_msg='set f1 frequency')
     npt.assert_almost_equal(dds.t2.frequency,
                             -fs / 8,
                             decimal=3,
                             err_msg='set f2 frequency')