Hallo, bin ein bisschen überfragt...
Ich habe ein Digitalmultimeter über rs232 an com1 (auch rs232) angeschlossen. Ich möchte nun die vom Multimeter gemessenen Daten auf meinen Computer übertragen.
Der Hersteller hat in seinen Handbuch einige Befehle zur Kommunikation gelistet, diese kann man senden um verschiedene Reaktionen, Ausgaben oder Abläufe zu steuern.
Wenn ich die Befehle über das Hyperterminal (von Windows) eingebe erhalte ich stets korrekte antworten vom Gerät (Multimeter)...-> Übertragung ist sichergestellt.
Was ich noch hinzufügen möchte ist das der Befehl in ASCII gesendet werden muss.
Im englischsprachigen Forum habe ich bereits einen script gefunden, dieser Funktioniert jedoch nicht einwandfrei (gar nicht)...-> das Gerät erkennt zwar das "etwas" ankommt gibt anschließend jedoch ständig ;Syntax - Fehler; aus.
Mein Betriebssystem ist Windows ME,
Verbindungsdaten: 9600 Bps, 0 Parität, 8 Bits (angeschlossen an COM1)
Hier ist der Skript den ich bereits versucht habe...
$MsComm = ObjCreate("MSCOMMLib.MsComm.1")
$MsComm.CommPort = 1
$MsComm.Settings = "9600,N,8,1"
$MsComm.Handshaking = 0
$MsComm.InBufferSize = 1024
$MsComm.InputLen = 1
$MsComm.PortOpen = 1
While 1
_MsgOut("DISP:TEXT 'Test'" & @CR)
MsgBox(0,"Testing",_MsgIn())
Sleep(2000)
WEnd
Func _MsgOut($str)
$MsComm.OutBufferCount = 0
$MsComm.InBufferCount = 0
If $MsComm.PortOpen = True Then
$MsComm.Output = $str
EndIf
$MsComm.InputLen = 0
EndFunc
Func _MsgIn()
$TIMEOUT = 1000
$nTimeCtr = 0
$sBuffer = ""
Do
$nTimeCtr += 1
If $MsComm.InBufferCount > 0 Then
$sBuffer = $sBuffer & $MsComm.Input
EndIf
Sleep(500)
Until StringInStr($sBuffer,@CR) OR $nTimeCtr > $TIMEOUT
If $nTimeCtr < $TIMEOUT Then
$nI = StringInStr($sBuffer,@CR)
Return StringLeft($sBuffer,$nI)
Else
Return "Error"
EndIf
EndFunc
Alles anzeigen
Über Hilfe in Form eines Skriptes das Befehle in ASCII sendet oder informationen über den Ablauf wie die Informationen weiter verarbeitet werden (vom Programm, Computer oder sonstigen Bestandteilen)
Vielen Dank im vorraus
( der Befehl der im Bsp. Skript gesendet wird heißt "DISP:TEXT 'Test'" )