Hy
Du benötigst mal die Port.dll
www.home.pages.at/troller507/PORT.DLL
Informationen für die RS232 Ansteuerung:
http://www.arcelect.com/rs232.htm
Deklarationen für Port.dll:
Declare Function OPENCOM Lib "Port" (ByVal A$) As Integer
Declare Sub CLOSECOM Lib "Port" ()
Declare Sub SENDBYTE Lib "Port" (ByVal b%)
Declare Function READBYTE Lib "Port" () As Integer
Declare Sub DTR Lib "Port" (ByVal b%)
Declare Sub RTS Lib "Port" (ByVal b%)
Declare Sub TXD Lib "Port" (ByVal b%)
Declare Function CTS Lib "Port" () As Integer
Declare Function DSR Lib "Port" () As Integer
Declare Function RI Lib "Port" () As Integer
Declare Function DCD Lib "Port" () As Integer
Declare Sub DELAY Lib "Port" (ByVal b%)
Declare Sub TIMEINIT Lib "Port" ()
Declare Sub TIMEINITUS Lib "Port" ()
Declare Function TIMEREAD Lib "Port" () As Long
Declare Function TIMEREADUS Lib "Port" () As Long
Declare Sub DELAYUS Lib "Port" (ByVal l As Long)
Declare Sub REALTIME Lib "Port" (ByVal i As Boolean)
Declare Sub OUTPORT Lib "Port" (ByVal A%, ByVal b%)
Declare Function INPORT Lib "Port" (ByVal p%) As Integer
Declare Function JOYX Lib "Port" () As Long
Declare Function JOYY Lib "Port" () As Long
Declare Function JOYZ Lib "Port" () As Long
Declare Function JOYW Lib "Port" () As Long
Declare Function JOYBUTTON Lib "Port" () As Integer
Declare Function SOUNDSETRATE Lib "Port" (ByVal Rate%) As Integer
Declare Function SOUNDGETRATE Lib "Port" () As Integer
Declare Function SOUNDBUSY Lib "Port" () As Boolean
Declare Function SOUNDIS Lib "Port" () As Boolean
Declare Sub SOUNDIN Lib "Port" (ByVal Puffer$, ByVal Size%)
Declare Sub SOUNDOUT Lib "Port" (ByVal Puffer$, ByVal Size%)
Declare Function SOUNDGETBYTES Lib "Port" () As Integer
Declare Function SOUNDSETBYTES Lib "Port" (ByVal b%) As Integer
Declare Sub SOUNDCAPIN Lib "Port" ()
Declare Sub SOUNCAPDOUT Lib "Port" () Kleines Beispiel für eine Abfrage von Eingängen der RS232 Schnittstelle:
Private Sub Form_Load()
i = OPENCOM("COM2,1200,N,8,1")
If i = 0 Then
i = OPENCOM("COM1,1200,N,8,1")
Option1.Value = True
End If
If i = 0 Then MsgBox ("Schnittstelle nicht verfügbar")
TXD 1
RTS 1
DTR 1
TIMEINIT
End Sub
Private Sub Option1_Click()
i = OPENCOM("COM1,1200,N,8,1")
If i = 0 Then MsgBox ("COM1 nicht verfügbar")
TXD 1
RTS 1
DTR 1
End Sub
Private Sub Option2_Click()
i = OPENCOM("COM2,1200,N,8,1")
If i = 0 Then MsgBox ("COM2 nicht verfügbar")
TXD 1
RTS 1
DTR 1
End Sub
Private Sub Timer1_Timer()
If CTS() = 1 Then Check1.Value = 1 Else Check1.Value = 0
If DSR() = 1 Then Check2.Value = 1 Else Check2.Value = 0
If DCD() = 1 Then Check3.Value = 1 Else Check3.Value = 0
If RI() = 1 Then Check4.Value = 1 Else Check4.Value = 0
End Sub Kleines Beispiel für Ausgaben:
Dim Ausgang As Integer
Private Sub Command1_Click()
Timer1.Interval = HScroll1.Value + 10
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
i = OPENCOM("COM2,1200,N,8,1")
If i = 0 Then MsgBox ("Schnittstelle nicht verfügbar")
Timer1.Interval = 250
Timer1.Enabled = True
Ausgang = 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
CLOSECOM
End Sub
Private Sub HScroll1_Change()
Timer1.Interval = HScroll1.Value + 10
End Sub
Private Sub Timer1_Timer()
If Ausgang = 1 Then Ausgang = 0 Else Ausgang = 1
If Ausgang = 1 Then DTR 1 Else DTR 0
End Sub LG |