15,907,913 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by AAhsan24 (Top 1 by date)
AAhsan24
28-Jan-21 8:21am
View
Thanks RickZeeland for help
After updating timer to event handler, my main Window Freeze while updating File.
Private Sub initCommPort()
If SerialPort1.IsOpen = False Then
SerialPort1.PortName = ListBox1.SelectedItem
SerialPort1.BaudRate = 115200
SerialPort1.Parity = Parity.None
SerialPort1.DataBits = 8
SerialPort1.StopBits = StopBits.One
SerialPort1.ReadTimeout = 100
'SerialPort1.ReceivedBytesThreshold = 100
SerialPort1.DiscardNull = True
Try
SerialPort1.Open()
rs232Timer.Interval = 1
rs232Timer.Start()
vcapMin1 = 9999
vcapMax1 = 0
vcapMin2 = 9999
vcapMax2 = 0
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
' ONCE PORT IS INITIALISED, RECEIPT OF DATA KICKS EVERYTHING OFF ...
End Sub
' This is the method to run when the rs232Timer is raised.
'Private Sub TimerEventProcessor(ByVal myObject As Object, ByVal myEventArgs As EventArgs) Handles rs232Timer.Tick
Private Sub SerialPort_DataReceived(sender As Object, e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
'rs232Timer.Stop()
Do
Try
Dim Incoming As String = SerialPort1.ReadLine()
If Incoming Is Nothing Then
Exit Do
Else
Dim packet As String = Incoming
Incoming = Nothing
If (RequestCmd > 0) Then
If SerialPort1.IsOpen = True Then
SerialPort1.Write(Chr(RequestCmd))
System.Diagnostics.Debug.WriteLine("CMD: " & RequestCmd)
RequestCmd = 0
Else
System.Diagnostics.Debug.WriteLine("CMD: " & RequestCmd)
End If
End If
Me.BeginInvoke(New StringSubPointer(AddressOf ProcessData), packet)
End If
Catch ex As Exception
Exit Do
End Try
Loop
'rs232Timer.Start()
End Sub
Private Sub ProcessData(ByVal Buffer As String)
Dim rawLine As String
If Buffer.Length > 0 Then
Select Case Mid(Buffer, 1, 1)
Case "P" 'PON registers
processPonRegs(Buffer)
If (Mid(Buffer, 2, 1) = "1") Then
If (p1Active = True) Then
rawLine = Mid(Buffer, 1, 2) & " " & Mid(Buffer, 3, 16) & " " & Mid(Buffer, 19, 16) & " " & Mid(Buffer, 35, 16) & " " & Mid(Buffer, 51, 16)
storeRawDataLine(rawLine, 2)
rawLine = " " & Mid(Buffer, 67, 16) & " " & Mid(Buffer, 83, 16) & " " & Mid(Buffer, 99, 16) & " " & Mid(Buffer, 115, 16)
storeRawDataLine(rawLine, 3)
End If
Else
If (p2Active = True) Then
rawLine = Mid(Buffer, 1, 2) & " " & Mid(Buffer, 3, 16) & " " & Mid(Buffer, 19, 16) & " " & Mid(Buffer, 35, 16) & " " & Mid(Buffer, 51, 16)
storeRawDataLine(rawLine, 4)
rawLine = " " & Mid(Buffer, 67, 16) & " " & Mid(Buffer, 83, 16) & " " & Mid(Buffer, 99, 16) & " " & Mid(Buffer, 115, 16)
storeRawDataLine(rawLine, 5)
End If
End If
Case "T" 'Trace Buffer Data
'saveTraceBufferLine(Buffer, TBConfiguration)
My.Computer.FileSystem.Writ