Changeset 4946
- Timestamp:
- 03/03/09 15:37:21 (4 years ago)
- Location:
- developers/werner/ahrt/host/tmc
- Files:
-
- 3 edited
-
lib/scope.py (modified) (1 diff)
-
lib/wave.py (modified) (3 diffs)
-
python.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
developers/werner/ahrt/host/tmc/lib/scope.py
r4857 r4946 452 452 center = (t0+t1)/2.0 453 453 self.hor.pos = center-trigger 454 455 456 class 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 2 2 # wave.py - Analog and digital waveforms 3 3 # 4 # Copyright (C) 2008 by OpenMoko, Inc.4 # Copyright (C) 2008, 2009 by OpenMoko, Inc. 5 5 # Written by Werner Almesberger <werner@openmoko.org> 6 6 # All Rights Reserved … … 115 115 def binary(self, other, op): 116 116 res = analog() 117 s = self.label118 if not s:119 s = ""120 if other.label:121 if s:122 s += "_"123 s += other.label124 117 if isinstance(self, wave): 118 s = self.label 119 if not s: 120 s = "" 125 121 if isinstance(other, wave): 122 if False: # other.label: 123 if s: 124 s += "_" 125 s += other.label 126 126 for v in waves(self, other).iterate(): 127 127 res.append(v[0], op(float(v[1]), float(v[2]))) … … 130 130 res.append(p[0], op(float(p[1]), float(other))) 131 131 else: 132 s = other.label 132 133 for p in other: 133 134 res.append(p[0], op(float(self), float(p[1]))) 135 res.label = s 134 136 return res 135 137 -
developers/werner/ahrt/host/tmc/python.c
r4631 r4946 2 2 * python.c - Python binding for TMC functions 3 3 * 4 * Copyright (C) 2008 by OpenMoko, Inc.4 * Copyright (C) 2008, 2009 by OpenMoko, Inc. 5 5 * Written by Werner Almesberger <werner@openmoko.org> 6 6 * All Rights Reserved … … 18 18 19 19 20 #define BUF_SIZE ( 1024*1024)20 #define BUF_SIZE (21*1024*1024) /* Tek MSO4000 can return about 20 MB */ 21 21 #define ERROR fprintf(stderr, "ERROR %d\n", __LINE__) 22 22 /* @@@FIXME: raise exceptions */ … … 26 26 struct tmc_dsc *instr; 27 27 }; 28 29 30 static char *buf; 28 31 29 32 … … 140 143 { 141 144 struct py_instr *s = (struct py_instr *) self; 142 static char buf[BUF_SIZE];143 145 int len; 144 146 … … 249 251 if (PyType_Ready(&tmc_instr_type) < 0) 250 252 return; 251 m = Py_InitModule3("_tmc", tmc_methods, "Test & Me surement Control");253 m = Py_InitModule3("_tmc", tmc_methods, "Test & Measurement Control"); 252 254 Py_INCREF(&tmc_instr_type); 253 255 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.
