sot bel
Member
Hello
I try to read string messages from serial port but messages comes splited.
Here is the code
-------------------------------------------------------------------------
Sub Process_Globals
Private sp As Serial
Private astream As AsyncStreams
End Sub
Sub AppStart (Form1 As Form, Args() As String)
sp.Initialize("sp")
Log(sp.ListPorts)
sp.Open("COM3") '*** COM PORT ***
sp.SetParams(9600, 8, 1, 0) '*** BAUD RATE ***
astream.Initialize(sp.GetInputStream, sp.GetOutputStream, "astream")
End Sub
Sub AStream_NewData (Buffer() As Byte)
Dim LogHeader As String = DateTime.Now & " " & Buffer.Length & " :"
Dim LogBytes As String = ""
For I = 0 To Buffer.Length - 1
LogBytes = LogBytes & " " & Buffer(I)
Next
Dim LogString As String = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
Log(LogString)
End Sub
------------------------------------------------------------------------
log window
-------------
Temperature for the device
1 (index 0) is: 28.12
Requesti
ng temperatures...
DONE
Temperature for the device
1 (index 0) is: 28.12
Requesti
ng temperatures...
DONE
Temperature for the device
1 (index 0) is: 28.00
Requesti
ng temperatures...
DONE
Temperature for the device
1 (index 0) is: 28.12
Requesti
ng temperatures...
DONE
Temperature for the device
1 (index 0) is: 28.19
Requesti
ng temperatures...
DONE
Temperature for the device
1 (index 0) is: 28.06
Requesti
ng temperatures...
-----------------------------------------------------------------------------------
what i expect
----------------
Dallas Temperature IC Control Library Demo
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.25
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.25
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.25
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.25
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.25
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.25
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.06
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.06
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.06
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.06
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.19
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.19
Requesting temperatures...DONE
I try to read string messages from serial port but messages comes splited.
Here is the code
-------------------------------------------------------------------------
Sub Process_Globals
Private sp As Serial
Private astream As AsyncStreams
End Sub
Sub AppStart (Form1 As Form, Args() As String)
sp.Initialize("sp")
Log(sp.ListPorts)
sp.Open("COM3") '*** COM PORT ***
sp.SetParams(9600, 8, 1, 0) '*** BAUD RATE ***
astream.Initialize(sp.GetInputStream, sp.GetOutputStream, "astream")
End Sub
Sub AStream_NewData (Buffer() As Byte)
Dim LogHeader As String = DateTime.Now & " " & Buffer.Length & " :"
Dim LogBytes As String = ""
For I = 0 To Buffer.Length - 1
LogBytes = LogBytes & " " & Buffer(I)
Next
Dim LogString As String = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
Log(LogString)
End Sub
------------------------------------------------------------------------
log window
-------------
Temperature for the device
1 (index 0) is: 28.12
Requesti
ng temperatures...
DONE
Temperature for the device
1 (index 0) is: 28.12
Requesti
ng temperatures...
DONE
Temperature for the device
1 (index 0) is: 28.00
Requesti
ng temperatures...
DONE
Temperature for the device
1 (index 0) is: 28.12
Requesti
ng temperatures...
DONE
Temperature for the device
1 (index 0) is: 28.19
Requesti
ng temperatures...
DONE
Temperature for the device
1 (index 0) is: 28.06
Requesti
ng temperatures...
-----------------------------------------------------------------------------------
what i expect
----------------
Dallas Temperature IC Control Library Demo
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.25
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.25
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.25
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.25
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.25
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.25
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.06
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.06
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.06
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.06
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.19
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 28.19
Requesting temperatures...DONE