Hi,
hier kurz der Code für die Kommunikation mit der Seriellen:
(ohne Kommentare und ausm Kopf aufgeschrieben und teilweise gecopypastet. Anpassung an die Applikation sind notwendig
)
Code:
' Declaration:
Public WithEvents Connection As System.IO.Ports.SerialPort
' Settings:
Connection.BaudRate = 9600
Connection.DataBits = 8
Connection.Handshake = IO.Ports.Handshake.None
Connection.Parity = IO.Ports.Parity.None
Connection.PortName = "COM1"
Connection.Encoding = System.Text.Encoding.ASCII
Connection.StopBits = IO.Ports.StopBits.One
Connection.Open()
' Threadworkaround:
Private Sub Connection_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles Connection.DataReceived
Invoke(New ReceiveHandler(AddressOf Receive), Connection.ReadExisting())
End Sub
Delegate Sub ReceiveHandler(ByVal data As String)
Public Sub Receive(ByVal text As String)
MessageBox.Show(text)
End Sub
Gruß, CowZ
Lesezeichen