Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27184

VS 2008 rs232

$
0
0
Hi

I have a lot of data coming through the rs232 port
If data starts with a capital letter "A to N" then it will be displayed on different labels.
Example of incoming data:
B12.7+ vbCrLf
E38.5+ vbCrLf
M124.8+ vbCrLf
all packets of incoming data finish with + vbCrLf

I tried this code, but it's not working (reliable), I mean it's displaying the data in the right labels only once randomly, mostly at start, then the labels are not updated anymore (though I see data coming into a textbox)
Quote:

Private Delegate Sub UpdateTextboxDelegate(ByVal myResponse As String)
..................
Private Sub SerialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort.DataReceived
Dim myResponse As Byte = SerialPort.ReadByte()
UpdateTextbox(myResponse)
End Sub

Private Sub UpdateTextbox(ByVal myResponse As String)
If Me.txt_inc.InvokeRequired Then
Dim d As New UpdateTextboxDelegate(AddressOf UpdateTextbox)
Me.txt_inc.Invoke(d, New Object() {myResponse})
Else
txt_inc.Text = myResponse


Select Case SerialPort.ReadByte
Case 66 'B
lbl_spd.Text = SerialPort.ReadLine
Case 67 'C
lbl_bt_val.Text = SerialPort.ReadLine
Case 68 'D
lbl_iny_val.Text = SerialPort.ReadLine
Case 69 'E
lbl_ot_val.Text = SerialPort.ReadLine
Case 70 'F
lbl_eo.Text = SerialPort.ReadLine '- 1
Case 71 'G
lbl_wtQo_val.Text = SerialPort.ReadLine
Case 72 'H
lbl_bx_val.Text = SerialPort.ReadLine
Case 73 'I
lbl_rd_val.Text = SerialPort.ReadLine

Case 74 'J
lbl_so.Text = SerialPort.ReadLine
Case 75 'K
lbl_ia_val.Text = SerialPort.ReadLine
Case 77 'M
lbl_by_val.Text = SerialPort.ReadLine
Case 78 'N
lbl_inne.Text = SerialPort.ReadLine
End Select
End If
End Sub
Can anybody give me a helping hand?

Thanks.

Viewing all articles
Browse latest Browse all 27184

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>