(这可能是错误的论坛,所以我在github上发起了一个问题https://github.com/hgrecco/pyvisa/issues/254)
我尝试在python中使用GPIB来控制Keithley乐器。基本上通信工作,但是当从仪器读取时,字符经常被破坏。 E.g:
rm = visa.ResourceManager()
inst = rm.open_resource('GPIB0::5::INSTR')
inst.write_termination = '\n'
inst.ask('*IDN?')
给出
'[EYTXLUY0I^STRUMUNTS0I^C>,]OTE\\ 2306,1178362,B16 /B02 \n'
在National Instruments VISA测试小组中看起来相反:
3: Write Operation (*IDN?\n)
Return Count: 6 bytes
4: Read Operation
Return Count: 57 bytes
KEITHLEY INSTRUMENTS INC.,MODEL 2306,1178362,B16 /B02 .
当我检查NI I / O Trace时,两个呼叫看起来都差不多:
NI测试小组:
3. viWrite (GPIB0::5::INSTR (0x01FBD908), "*IDN?.", 6, 6)
Process ID: 0x000013E0 Thread ID: 0x00001390
Start Time: 12:57:52.691 Call Duration 00:00:00.022
Status: 0 (VI_SUCCESS)
4. viRead (GPIB0::5::INSTR (0x01FBD908), "KEITHLEY INSTRUMENTS ...", 1024, 57)
Process ID: 0x000013E0 Thread ID: 0x00001390
Start Time: 12:57:52.892 Call Duration 00:00:00.028
Status: 0 (VI_SUCCESS)
的Python:
5. viWrite (GPIB0::5::INSTR (0x02B67068), "*IDN?.", 6, 6)
Process ID: 0x0000017C Thread ID: 0x000007AC
Start Time: 10:27:22.794 Call Duration 00:00:00.013
Status: 0 (VI_SUCCESS)
6. viRead (GPIB0::5::INSTR (0x02B67068), "[EYTXLUY0I^STRUMUNTS0...", 20480, 57)
Process ID: 0x0000017C Thread ID: 0x000007AC
Start Time: 10:27:22.808 Call Duration 00:00:00.020
Status: 0 (VI_SUCCESS)
有人有想法吗?
py -m visa info
Machine Details:
Platform ID: Windows-7-6.1.7601-SP1
Processor: x86 Family 6 Model 42 Stepping 7, GenuineIntel
Python:
Implementation: CPython
Executable: C:\Users\vos\AppData\Local\Programs\Python\Python36-32\python.exe
Version: 3.6.0
Compiler: MSC v.1900 32 bit (Intel)
Bits: 32bit
Build: Dec 23 2016 07:18:10 (#v3.6.0:41df79263a11)
Unicode: UCS4
PyVISA Version: 1.8
Backends:
ni:
Version: 1.8 (bundled with PyVISA)
#1: C:\Windows\system32\visa32.dll:
found by: auto
bitness: 32
Vendor: National Instruments
Impl. Version: 15728640
Spec. Version: 5243904
#2: C:\Windows\system32\visa32.dll:
found by: auto
bitness: 32
Vendor: National Instruments
Impl. Version: 15728640
Spec. Version: 5243904
python中的其他命令:
>>> inst.ask(':FETC?')
'+4.99963273E+00\n'
似乎是正确的,但事实并非如此:
>>> inst.ask(':FETC:ARR?')
';4>99964076E;00,;4>99963733E;00,;4>99963424E;00,;4>99962772E;00,+4.99962361E+00\n'
从NI VISA Interactive Control进行比较:
1: Write Operation (:FETC?)
Return Count: 6 bytes
2: Read Operation
Return Count: 16 bytes
+4.99963273E+00\n
3: Write Operation (:FETC:ARR?)
Return Count: 10 bytes
4: Read Operation
Return Count: 80 bytes
+4.99964076E+00,+4.99963733E+00,+4.99963424E+00,+4.99962772E+00,
+4.99962361E+00\n