fc43fbe4b0
- Merged four separate hardware control projects into unified platform - Created unified requirements.txt with all dependencies - Added comprehensive .gitignore - Added project overview README Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
78 lines
2.8 KiB
Python
Executable File
78 lines
2.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Simple focused test for waveform transfer functionality.
|
|
"""
|
|
|
|
from tektronix_base import TektronixOscilloscopeBase
|
|
|
|
|
|
def main():
|
|
"""Simple test of core waveform transfer on CH1"""
|
|
|
|
scope_ip = "192.168.10.105"
|
|
|
|
print(f"Connecting to oscilloscope at {scope_ip}...")
|
|
|
|
scope = TektronixOscilloscopeBase(resource_name=scope_ip, timeout=10.0)
|
|
|
|
try:
|
|
# Connect to scope
|
|
scope.connect()
|
|
print(f"Connected to {scope.identify()}\n")
|
|
|
|
# Test 1: Configure and transfer using low-level methods
|
|
print("=== Test 1: Low-level waveform transfer ===")
|
|
print("Configuring data transfer settings...")
|
|
scope.set_data_encoding('RIBinary')
|
|
scope.set_wfmoutpre_encoding('BINary')
|
|
scope.set_wfmoutpre_byte_count(1)
|
|
scope.set_wfmoutpre_byte_order('MSB')
|
|
scope.set_data_source('CH1')
|
|
|
|
print("Transferring curve data from CH1...")
|
|
curve_data = scope.transfer_curve()
|
|
print(f" Received {len(curve_data)} bytes")
|
|
|
|
print("Parsing curve data...")
|
|
values = scope.parse_curve_data(curve_data, byte_count=1, signed=True, byte_order='MSB')
|
|
print(f" Parsed {len(values)} samples")
|
|
print(f" First 10 values: {values[:10]}")
|
|
print(f" Min: {min(values)}, Max: {max(values)}, Avg: {sum(values)/len(values):.2f}")
|
|
|
|
# Test 2: Use high-level acquire_waveform method
|
|
print("\n=== Test 2: High-level waveform acquisition ===")
|
|
print("Acquiring waveform from CH1...")
|
|
waveform = scope.acquire_waveform('CH1')
|
|
print(f" Acquired {len(waveform)} samples")
|
|
print(f" First 10 values: {waveform[:10]}")
|
|
print(f" Min: {min(waveform)}, Max: {max(waveform)}, Avg: {sum(waveform)/len(waveform):.2f}")
|
|
|
|
# Test 3: Query waveform preamble
|
|
print("\n=== Test 3: Waveform preamble ===")
|
|
preamble = scope.query_wfmoutpre()
|
|
print(f" Preamble: {preamble[:150]}...")
|
|
|
|
# Test 4: Transfer complete waveform (preamble + curve)
|
|
print("\n=== Test 4: Complete waveform transfer ===")
|
|
print("Transferring complete waveform...")
|
|
preamble_str, curve_bytes = scope.transfer_waveform()
|
|
print(f" Preamble length: {len(preamble_str)} chars")
|
|
print(f" Curve data: {len(curve_bytes)} bytes")
|
|
wf_values = scope.parse_curve_data(curve_bytes, byte_count=1, signed=True, byte_order='MSB')
|
|
print(f" Parsed {len(wf_values)} samples")
|
|
|
|
print("\n=== All tests completed successfully! ===")
|
|
|
|
except Exception as e:
|
|
print(f"\nError: {type(e).__name__}: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
finally:
|
|
if scope.is_connected:
|
|
scope.disconnect()
|
|
print("\nDisconnected from oscilloscope")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|