public Sub openport As Boolean
If com.ListPorts.IndexOf(comparam.port) > -1 Then
If opened Then
closeport
End If
Try
'Breakpoint here
com.Open(comparam.port)
com.SetParams(comparam.speed,comparam.databit,comparam.stopbit,comparam.parity)
astream.Initialize(com.GetInputStream, com.GetOutputStream, "astream")
opened = True
Log($"${comparam.port} opened"$)
Return True
Catch
Log(LastException)
Return False
End Try
Else
Return False
End If
End Sub
public Sub startmeres
'Breakpoint here
Log($"${comparam.port} data sending"$)
Select comparam.protokoll
Case "F501"
Dim b() As Byte = Array As Byte (2,5,3)
astream.Write(b)
Case "Dollar"
astream.Write("$".GetBytes("ASCII"))
End Select
End Sub
'----------------------------------------------------------
'can't happen AStream_NewData without a brekpoint
Sub AStream_NewData (Buffer() As Byte)
Dim s As String = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
Log($"${comparam.port} data arrived ${s}"$)
If SubExists(resobj,"serial_result") Then
CallSubDelayed2(resobj,"serial_result",s)
Else
Log($"serial_result not found!"$)
End If
End Sub