Am 21.05.2014 14:28, schrieb Norbert Hoppe - FH Brandenburg:
Hallo Liste,
ich möchte ein Tischmultimeter via Ethernet und GPIB-Lan-Adapter steuern. OS: Ubuntu 12.04 Python Version: 3.3 GPIB_Lan-Adapter: Prologix (siehe www.stantronic.de/GPIB-LAN.html) Multimeter: HP34401A, Adresse 22, Sprache SCPI meine Kenntnisse: Einsteiger
Die Kommunikation über telnet funktioniert problemlos: telnet 172.16.3.7 1234 Trying 172.16.3.7... Connected to 172.16.3.7. Escape character is '^]'. ++auto 0 ++addr 22 GPIB-Geräteadresse festlegen *IDN? Identifier des Gerätes abfragen Antwort abholen: ++read eoi HEWLETT-PACKARD,34401A,0,4-1-1 MEAS:VOLT:DC? Gleichspannungsmessung auslösen Antwort abholen: ++read eoi Messwert holen +8.88698400E+00
Wie realisiere ich das unter Python3?
Mein bisheriger Code:
import socket
HOST = '172.16.3.7' PORT = 1234
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST,PORT))
senddata = '++addr 22' s.send(senddata.encode('utf-8'))
senddata = '*IDN?' s.send(senddata.encode('utf-8'))
senddata = '++read eoi' s.send(senddata.encode('utf-8'))
data = s.recv(30)
s.close print("Empfangen: ", repr(data))
Wenn ich das als Script ausführe, dann schein es hängen zu bleiben. Drücken von Ctrl+C führt zu folgender Meldung ^CTraceback (most recent call last): File "./dmm.py", line 34, in <module> data = s.recv(30) KeyboardInterrupt
Am Multimeter gibt es keine Fehlermeldung. Wie macht man es richtig?
Vermutlich musst Du jeweils an Deine senddata strings einen Linefeed, ein Carriage Return, oder beides anhängen. Thomas