Changeset 4946


Ignore:
Timestamp:
03/03/09 15:37:21 (4 years ago)
Author:
werner
Message:
  • python.c: increase buffer size from 1 MB to > 20 MB
  • lib/scope.py: added basic support for Tektronix MSO4000 series
  • lib/wave.py: label assignment logic in "binary" incorrectly assumed that we only use waves, no scalars
Location:
developers/werner/ahrt/host/tmc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • developers/werner/ahrt/host/tmc/lib/scope.py

    r4857 r4946  
    452452            center = (t0+t1)/2.0 
    453453            self.hor.pos = center-trigger 
     454 
     455 
     456class tektronix_mso4000(scope): 
     457    channels = 4 
     458    div_hor = 10 
     459    div_vert = 10 
     460    samples_per_div = 50        # ??? 
     461 
     462    def __init__(self): 
     463        scope.__init__(self, "usbtmc", "timeout=10", "retry", 
     464          "vendor=0x0699", "product=0x0401") 
     465        self.ch = [] 
     466        self.d = map(lambda x: x, range(0, 16)) 
     467        for n in range(1, self.channels+1): 
     468            self.ch.append(channel(self, n)) 
     469        self.trigger = None 
     470        self.hor = horizontal(self) 
     471        self.lock_attr() 
     472 
     473# for now, we treat it almost like a Rigol 
     474 
     475    def forget(self): 
     476        for ch in self.ch: 
     477            ch.forget() 
     478        self.hor.forget() 
     479 
     480    def download_wave(self, channel, start, end, step): 
     481        self.send(":DATA:SOU CH"+str(channel.number)) 
     482        self.send(":DATA:ENC RPB") 
     483        self.send(":WFMO:BYT_NR 1") 
     484        self.send(":CURVE B") 
     485        s = self.query(":WFMO?") 
     486        info = s.split(";") 
     487        pts = info[6] 
     488        hincr = float(info[9]) 
     489        hzero = float(info[10]) 
     490        vincr = float(info[13]) 
     491        vzero = float(info[14]) 
     492        start = 400000 
     493        self.send(":DATA:START "+str(start)) 
     494        self.send(":DATA:STOP 700000") 
     495        d = self.query(":CURVE?") 
     496        digits = int(d[1]) 
     497        d = d[2+digits:-1] 
     498        wave = analog() 
     499        t = hzero+hincr*start 
     500        for c in d: 
     501            wave.append(t, (ord(c)-vzero)*vincr) 
     502            t += hincr 
     503        return wave 
     504 
     505    def sampling_rate(self): 
     506        return float(self.query(":ACQ:SAMP? CH1")) 
     507 
     508    def screendump(self): 
     509        self.send(":SAV:IMAG:FILEF PNG"); 
     510        return self.query(":HARDCOPY START") 
     511 
     512    def wave(self, channels, start = None, end = None, step = None): 
     513        if not hasattr(channels, "__iter__"): 
     514            return self.wave([channels], start, end, step)[0] 
     515        la = None 
     516        res = waves() 
     517        for ch in channels: 
     518            if isinstance(ch, channel): 
     519                res.append(self.download_wave(ch, start, end, step)) 
     520                res[-1].label = ch.name 
     521            else: 
     522                if la is None: 
     523                    la = self.download_la(start, end, step) 
     524                res.append(la[ch]) 
     525                res[-1].label = "D"+str(ch) 
     526        return res 
  • developers/werner/ahrt/host/tmc/lib/wave.py

    r4857 r4946  
    22# wave.py - Analog and digital waveforms 
    33# 
    4 # Copyright (C) 2008 by OpenMoko, Inc. 
     4# Copyright (C) 2008, 2009 by OpenMoko, Inc. 
    55# Written by Werner Almesberger <werner@openmoko.org> 
    66# All Rights Reserved 
     
    115115    def binary(self, other, op): 
    116116        res = analog() 
    117         s = self.label 
    118         if not s: 
    119             s = "" 
    120         if other.label: 
    121             if s: 
    122                 s += "_" 
    123             s += other.label 
    124117        if isinstance(self, wave): 
     118            s = self.label 
     119            if not s: 
     120                s = "" 
    125121            if isinstance(other, wave): 
     122                if False: # other.label: 
     123                    if s: 
     124                        s += "_" 
     125                    s += other.label 
    126126                for v in waves(self, other).iterate(): 
    127127                    res.append(v[0], op(float(v[1]), float(v[2]))) 
     
    130130                    res.append(p[0], op(float(p[1]), float(other))) 
    131131        else: 
     132            s = other.label 
    132133            for p in other: 
    133134                res.append(p[0], op(float(self), float(p[1]))) 
     135        res.label = s 
    134136        return res 
    135137 
  • developers/werner/ahrt/host/tmc/python.c

    r4631 r4946  
    22 * python.c - Python binding for TMC functions 
    33 * 
    4  * Copyright (C) 2008 by OpenMoko, Inc. 
     4 * Copyright (C) 2008, 2009 by OpenMoko, Inc. 
    55 * Written by Werner Almesberger <werner@openmoko.org> 
    66 * All Rights Reserved 
     
    1818 
    1919 
    20 #define BUF_SIZE (1024*1024) 
     20#define BUF_SIZE (21*1024*1024) /* Tek MSO4000 can return about 20 MB */ 
    2121#define ERROR fprintf(stderr, "ERROR %d\n", __LINE__) 
    2222        /* @@@FIXME: raise exceptions */ 
     
    2626        struct tmc_dsc *instr; 
    2727}; 
     28 
     29 
     30static char *buf; 
    2831 
    2932 
     
    140143{ 
    141144        struct py_instr *s = (struct py_instr *) self; 
    142         static char buf[BUF_SIZE]; 
    143145        int len; 
    144146 
     
    249251        if (PyType_Ready(&tmc_instr_type) < 0) 
    250252                return; 
    251         m = Py_InitModule3("_tmc", tmc_methods, "Test & Mesurement Control"); 
     253        m = Py_InitModule3("_tmc", tmc_methods, "Test & Measurement Control"); 
    252254        Py_INCREF(&tmc_instr_type); 
    253255        PyModule_AddObject(m, "Instr", (PyObject *) &tmc_instr_type); 
    254 } 
     256        buf = malloc(BUF_SIZE); 
     257        if (!buf) { 
     258                perror("malloc"); 
     259                exit(1); 
     260        } 
     261} 
Note: See TracChangeset for help on using the changeset viewer.