- 'nen Scheck brauche ich nicht, sondern mehr Zeit (falls du welche zu verschenken hast).
- Tot bin ich nicht, ich stell mich nur manchmal tot.
- Eine UDF gibt es im Prinzip schon, nur nicht für alle Leitungen/Pins -> Link .
- Hier mal ein Prog, was auf das unbedingt Nötige beschränkt ist:
[autoit]; *** Com1 öffnen:
$hSerialPort = DllCall("kernel32.dll","hwnd","CreateFile","str","\\.\com1","int",0xC0000000,"int",0,"ptr",0,"int",3,"int",0,"int",0)
; *** Ausgänge steuern:
; 0,5 Sek für's menschliche Auge:
Sleep(500)
; Alle Output-Pins mittels WinAPI 'EscapeCommFunction' auf ca.-12V setzen:
DllCall("kernel32.dll","long","EscapeCommFunction","hwnd", $hSerialPort[0],"long", 4) ;4=CLRRTS; set RTS low
DllCall("kernel32.dll","long","EscapeCommFunction","hwnd", $hSerialPort[0],"long", 6) ;6=CLRDTR; set DTR low
DllCall("kernel32.dll","long","EscapeCommFunction","hwnd", $hSerialPort[0],"long", 9) ;9=CLRBREAK; set TxD low
; 0,5 Sek für's menschliche Auge:
Sleep(500)
; Alle Output-Pins mittels WinAPI 'EscapeCommFunction' auf ca. +12V setzen:
DllCall("kernel32.dll","long","EscapeCommFunction","hwnd", $hSerialPort[0],"long", 3) ;3=SETRTS; set RTS high
DllCall("kernel32.dll","long","EscapeCommFunction","hwnd", $hSerialPort[0],"long", 5) ;5=SETDTR; set DTR high
DllCall("kernel32.dll","long","EscapeCommFunction","hwnd", $hSerialPort[0],"long", ;8=SETBREAK; set TxD high (break); *** Eingänge lesen:
; Struktur mit einem Element für das Lesen der Eingänge erzeugen:
$lpModemStat = DllStructCreate("DWORD")
; Input-Pins mittels WinAPI 'GetCommModemStatus' lesen:
DllCall("kernel32.dll", "long", "GetCommModemStatus", "HWND", $hSerialPort[0], "Ptr", DllStructGetPtr($lpModemStat))
$iPinState = DllStructGetData($lpModemStat, 1) ;Zustand der Pins nach $iPinState
; Werte für einzelne Pins isolieren:
$sCTS = " CTS=off "
If BitAND($iPinState, 0x10) Then $sCTS = " CTS=ON " ;0x10 = MS_CTS_ON
$sDSR = " DSR=off "
If BitAND($iPinState, 0x20) Then $sDSR = " DSR=ON " ;0x20 = MS_DSR_ON
$sRing = " Ring=off "
If BitAND($iPinState, 0x40) Then $sRing = " Ring=ON " ;0x40 = MS_RING_ON
$sDCD = " DCD=off "
If BitAND($iPinState, 0x80) Then $sDCD = " DCD=ON " ;0x80 = MS_RLSD_ON
; PinStatus anzeigen:
MsgBox(0, " Com-Port", $sCTS & $sDSR & $sRing & $sDCD); *** ComPort schließen:
[/autoit]
DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hSerialPort[0]) ;Win-API
Steini