當前位置: 首頁>>代碼示例>>Python>>正文


Python LibUsbScope.Oscilloscope類代碼示例

本文整理匯總了Python中PyHT6022.LibUsbScope.Oscilloscope的典型用法代碼示例。如果您正苦於以下問題:Python Oscilloscope類的具體用法?Python Oscilloscope怎麽用?Python Oscilloscope使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Oscilloscope類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_find_device

 def test_find_device(self):
     print "Testing finding device and flashing stock firmware."
     scope = Oscilloscope()
     assert scope.setup()
     assert scope.open_handle()
     assert scope.flash_firmware()
     assert scope.close_handle()
開發者ID:baruch,項目名稱:Hantek6022API,代碼行數:7,代碼來源:LibUsbScopeTest.py

示例2: test_set_one_channel_and_read

 def test_set_one_channel_and_read(self):
     print "Testing setting one channel and reading it."
     scope = Oscilloscope()
     assert scope.setup()
     assert scope.open_handle()
     assert scope.flash_firmware(mod_firmware_01)
     assert scope.set_ch1_voltage_range(0xA)
     assert scope.set_sample_rate(0x10)
     assert scope.set_num_channels(1)
     ch1_data, ch2_data = scope.read_data(0x4000)
     assert ch1_data
     assert not ch2_data
     assert scope.close_handle()
開發者ID:baruch,項目名稱:Hantek6022API,代碼行數:13,代碼來源:LibUsbScopeTest.py

示例3: test_data_scaling

 def test_data_scaling(self):
     print "Testing setting various scale facotrs and reading."
     scale_factor = 0x01
     scope = Oscilloscope()
     assert scope.setup()
     assert scope.open_handle()
     assert scope.flash_firmware()
     assert scope.set_ch1_voltage_range(scale_factor)
     assert scope.set_sample_rate(27)
     ch1_data, _ = scope.read_data(0x100000)
     ch1_data = scope.scale_read_data(ch1_data, scale_factor)
     print "Max:", max(ch1_data), "(V), Min:", min(ch1_data), "(V)"
     assert ch1_data
     assert scope.close_handle()
開發者ID:baruch,項目名稱:Hantek6022API,代碼行數:14,代碼來源:LibUsbScopeTest.py

示例4: test_flash_firmware

 def test_flash_firmware(self):
     print "Testing flashing multiple firmwares."
     scope = Oscilloscope()
     assert scope.setup()
     assert scope.open_handle()
     assert scope.flash_firmware(stock_firmware, supports_single_channel=False)
     assert scope.flash_firmware(mod_firmware_01)
     assert scope.flash_firmware(stock_firmware, supports_single_channel=False)
     assert scope.close_handle()
開發者ID:baruch,項目名稱:Hantek6022API,代碼行數:9,代碼來源:LibUsbScopeTest.py

示例5: test_set_sample_rate

 def test_set_sample_rate(self):
     print "Testing setting the sample rate."
     scope = Oscilloscope()
     assert scope.setup()
     assert scope.open_handle()
     assert scope.flash_firmware()
     for rate_index in scope.SAMPLE_RATES.keys():
         scope.set_sample_rate(rate_index)
     assert scope.close_handle()
開發者ID:baruch,項目名稱:Hantek6022API,代碼行數:9,代碼來源:LibUsbScopeTest.py

示例6: test_set_num_channels

 def test_set_num_channels(self):
     print "Testing setting the number of channels with modified firmware."
     scope = Oscilloscope()
     assert scope.setup()
     assert scope.open_handle()
     assert scope.flash_firmware(mod_firmware_01)
     assert scope.set_num_channels(1)
     assert scope.set_num_channels(2)
     assert scope.set_num_channels(1)
     assert scope.close_handle()
開發者ID:baruch,項目名稱:Hantek6022API,代碼行數:10,代碼來源:LibUsbScopeTest.py

示例7: test_clear_fifo

 def test_clear_fifo(self):
     print "Testing explicitly clearing the FIFO."
     scope = Oscilloscope()
     assert scope.setup()
     assert scope.open_handle()
     assert scope.flash_firmware()
     assert scope.clear_fifo()
     assert scope.close_handle()
開發者ID:baruch,項目名稱:Hantek6022API,代碼行數:8,代碼來源:LibUsbScopeTest.py

示例8: test_read_firmware

 def test_read_firmware(self):
     print "Testing read_firmware method on scope."
     scope = Oscilloscope()
     assert scope.setup()
     assert scope.open_handle()
     assert scope.flash_firmware()
     assert scope.read_firmware()
     assert scope.close_handle()
開發者ID:baruch,項目名稱:Hantek6022API,代碼行數:8,代碼來源:LibUsbScopeTest.py

示例9: test_get_cal_values

 def test_get_cal_values(self):
     print "Testing getting calibration values."
     scope = Oscilloscope()
     assert scope.setup()
     assert scope.open_handle()
     assert scope.flash_firmware()
     cal_values = scope.get_calibration_values()
     assert cal_values
     assert scope.close_handle()
開發者ID:baruch,項目名稱:Hantek6022API,代碼行數:9,代碼來源:LibUsbScopeTest.py

示例10: test_set_channel_voltage_range

 def test_set_channel_voltage_range(self):
     print "Testing setting the voltage range."
     scope = Oscilloscope()
     assert scope.setup()
     assert scope.open_handle()
     assert scope.flash_firmware()
     for vrange in scope.VOLTAGE_RANGES.keys():
         assert scope.set_ch1_voltage_range(vrange)
         assert scope.set_ch1_voltage_range(vrange)
     assert scope.close_handle()
開發者ID:baruch,項目名稱:Hantek6022API,代碼行數:10,代碼來源:LibUsbScopeTest.py

示例11: test_read_data

 def test_read_data(self):
     print "Testing reading data from the oscilloscope."
     scope = Oscilloscope()
     assert scope.setup()
     assert scope.open_handle()
     assert scope.flash_firmware()
     ch1_data, _ = scope.read_data(data_size=0x400)
     print ch1_data
     assert ch1_data
     assert scope.close_handle()
開發者ID:baruch,項目名稱:Hantek6022API,代碼行數:10,代碼來源:LibUsbScopeTest.py

示例12: initialize

    def initialize(self):
        self.sample_rate_index = 8
        self.voltage_range = 0x01
        self.data_points = 3 * 1024

        self.trigger_level = 150
        self.trigger_type = +1

        self.scope = Oscilloscope()
        self.scope.setup()
        self.scope.open_handle()
        if (not self.scope.is_device_firmware_present):
            self.scope.flash_firmware()
        self.scope.set_interface(1); # choose ISO
        self.scope.set_num_channels(1)
        self.scope.set_sample_rate(self.sample_rate_index)
        self.scope.set_ch1_voltage_range(self.voltage_range)
        time.sleep(0.1)
        return None
開發者ID:GrahamW,項目名稱:Hantek6022API,代碼行數:19,代碼來源:mine.py

示例13: test_read_many_sizes

 def test_read_many_sizes(self):
     print "Testing reading many different data sizes"
     scope = Oscilloscope()
     assert scope.setup()
     assert scope.open_handle()
     assert scope.flash_firmware()
     data_size = 0x400
     for _ in xrange(11):
         print "DATA SIZE", data_size
         ch1_data, ch2_data = scope.read_data(data_size=data_size, raw=True)
         print len(ch1_data)
         print len(ch2_data)
         assert ch1_data, ch2_data
         data_size <<= 1
     assert scope.close_handle()
開發者ID:baruch,項目名稱:Hantek6022API,代碼行數:15,代碼來源:LibUsbScopeTest.py

示例14: Oscilloscope

from struct import pack
import sys
import time
from collections import deque

from PyHT6022.LibUsbScope import Oscilloscope

voltagerange = 10       # 1 (5V), 2 (2.6V), 5 or 10
samplerate = 24         # sample rate in MHz or in 10khz
numchannels = 1
numseconds = 8          # number of seconds to sample
blocksize = 6*1024      # should be divisible by 6*1024
alternative = 1         # choose ISO 3072 bytes per 125 us

scope = Oscilloscope()
scope.setup()
scope.open_handle()
scope.flash_firmware()
if (not scope.is_device_firmware_present):
    scope.flash_firmware()
else:
    scope.supports_single_channel = True;
print "Setting up scope!"

scope.set_interface(alternative);
print "ISO" if scope.is_iso else "BULK", "packet size:", scope.packetsize
print scope.set_num_channels(numchannels)
# set voltage range
scope.set_ch1_voltage_range(voltagerange)
# set sample rate
開發者ID:baruch,項目名稱:Hantek6022API,代碼行數:30,代碼來源:example_linux_recordwav.py

示例15: ScopeInterface

class ScopeInterface(QObject):
    new_data = pyqtSignal(list)
    def __init__(self, parent=None):
        super(ScopeInterface, self).__init__(parent)
        self.inprogress = False

    def initialize(self):
        self.sample_rate_index = 8
        self.voltage_range = 0x01
        self.data_points = 3 * 1024

        self.trigger_level = 150
        self.trigger_type = +1

        self.scope = Oscilloscope()
        self.scope.setup()
        self.scope.open_handle()
        if (not self.scope.is_device_firmware_present):
            self.scope.flash_firmware()
        self.scope.set_interface(1); # choose ISO
        self.scope.set_num_channels(1)
        self.scope.set_sample_rate(self.sample_rate_index)
        self.scope.set_ch1_voltage_range(self.voltage_range)
        time.sleep(0.1)
        return None

    def capture(self):
        if not self.inprogress:
            self.inprogress = True
            self.scope.start_capture()
            shutdown_event = self.scope.read_async(self.data_callback, self.data_points, outstanding_transfers=25)
            print("Clearing FIFO and starting data transfer...")

    def data_callback(self, ch1_data, _):
        d = list(ch1_data)
        i = 0
        #print("got new data ", time.time(), " : ", len(d))
        if self.trigger_type > 0:
            while (i < len(d) - 1) and not (d[i+1] > self.trigger_level and d[i] < self.trigger_level):
                i += 1
        #print("Trigger at ", i)
        if (i != len(d) - 1):
            self.new_data.emit(d[i:])


    def stop(self):
        self.scope.stop_capture()
        print("Stopping new transfers.")
        shutdown_event.set()
        print("Snooze 1")
        time.sleep(1)
        print("Closing handle")
        self.scope.close_handle()
        print("Handle closed.")
        self.inprogress = False
開發者ID:GrahamW,項目名稱:Hantek6022API,代碼行數:55,代碼來源:mine.py


注:本文中的PyHT6022.LibUsbScope.Oscilloscope類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。