Danke Danke habe den Fehler Korrigiert. Habs auch oben abgeändert. Die Abfrage ob der String länger ist bau ich dann später noch ein.
In VB2010 habe ich das Senden eines Befehls so angestellt:
Verbindungsbutton RS232:
PHP-Code:
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Try
SerialPort1.PortName = TextBox12.Text
SerialPort1.BaudRate = TextBox13.Text
SerialPort1.DataBits = 8
SerialPort1.StopBits = IO.Ports.StopBits.One
SerialPort1.Parity = IO.Ports.Parity.None
SerialPort1.Handshake = IO.Ports.Handshake.None
SerialPort1.Open()
Button2.Enabled = False
Button1.Enabled = True
Button3.Enabled = True
Button4.Enabled = True
Button5.Enabled = True
Button6.Enabled = True
Button7.Enabled = True
ProgressBar1.Value = 100
MsgBox("Connected")
Catch ex As Exception
ProgressBar1.Value = 0
MsgBox("Connection Error 001")
End Try
End Sub
SendeButton:
PHP-Code:
Private Sub Button7_Click(sender As System.Object, e As System.EventArgs) Handles Button7.Click
Dim buffer(200) As Byte
Dim offset As Integer
Dim count As Integer
Dim returnValue As Integer
offset = 0
count = 17
SerialPort1.Write(vbCr)
SerialPort1.Write("TEMP1")
SerialPort1.Write(vbCr)
System.Threading.Thread.Sleep(1000)
Dim IncommingData = SerialPort1.ReadExisting
TextBox15.Text = IncommingData
End Sub
Lesezeichen