Ich hatte mal eine kleine UDF für die serielle Schnittstelle geschrieben: SerialComm.au3 (eine kleine UDF zum Datenaustausch mit dem Arduino)
Das Beispiel ist zwar für AutoIt <-> Arduino, aber beim ESP8266 funktioniert das genauso.
Danke schonmal für deine Antwort. Ich habe jetzt folgenden Script am Laufen der funktioniert:
Code
#include <WinAPI.au3>
Dim $nBytes
Global $COMPort = "COM4"
Global $instr = ""
Global $Input = _WinAPI_CreateFile($COMPort, 2, 2)
Global $tBuffer = DllStructCreate("char[8]")
While 1
_WinAPI_ReadFile($Input, DllStructGetPtr($tBuffer), 1, $nBytes)
$instr = String($instr & BinaryToString(DllStructGetData($tBuffer, 1)))
If (StringLen($instr) = 8) Then
ConsoleWrite($instr & @CRLF)
$instr = ""
$nBytes = ""
sleep (500)
EndIf
WEnd
Alles anzeigen
Jetzt möchte ich aber 2 Arduinos verwenden bzw 2 COM Ports. Habe jetzt den Script so umgeschrieben aber leider funktioniert jetzt gar nichts mehr. Gar kein Output in der Konsole:
Code
#include <WinAPI.au3>
Dim $nBytes_A
Global $COMPort_A = "COM4"
Global $instr_A = ""
Global $Input_A = _WinAPI_CreateFile($COMPort_A, 2, 2)
Global $tBuffer_A = DllStructCreate("char[8]")
Dim $nBytes_B
Global $COMPort_B = "COM6"
Global $instr_B = ""
Global $Input_B = _WinAPI_CreateFile($COMPort_B, 2, 2)
Global $tBuffer_B = DllStructCreate("char[8]")
While 1
_WinAPI_ReadFile($Input_A, DllStructGetPtr($tBuffer_A), 1, $nBytes_A)
$instr_A = String($instr_A & BinaryToString(DllStructGetData($tBuffer_A, 1)))
_WinAPI_ReadFile($Input_B, DllStructGetPtr($tBuffer_B), 1, $nBytes_B)
$instr_B = String($instr_B & BinaryToString(DllStructGetData($tBuffer_B, 1)))
If (StringLen($instr_A) = 8) Then
ConsoleWrite($instr_A & @CRLF)
$instr_A = ""
$nBytes_A = ""
sleep (500)
EndIf
If (StringLen($instr_B) = 8) Then
ConsoleWrite($instr_B & @CRLF)
$instr_B = ""
$nBytes_B = ""
sleep (500)
EndIf
WEnd
Alles anzeigen
Hättest du da evtl ne Idee für mich woran das liegt bzw wie ich das zum Laufen bekomme?