Driver_Corrupted_MMPOOL

mrsgrams1

New member
Joined
Aug 29, 2003
Messages
4
Location
Fargo, ND
This is the first application I have written in VB.Net. I have a com control that I am using to communicate with scoreboards via virtual com ports.

I have one com control, and 5 scoreboards that i am writing information to. The com port settings are changed based on database information. In other words, the one com control is used dynamically to write to however many boards are in the database table. The problem is, the program will run for a max of 30 minutes, and then it actually gives me a blue screen of death (on XP!) and reboots my computer. It seems to have some kind of a build up that causes it to shut down. I just disabled the com control portion of the program, and it is ticking along just fine...going on 50 minutes now. Does anyone have any suggestions on this? This is my first situation dealing with serial communication and I am a little stumped!

here is the code:
-------------------------------------------------------
#Region "Public Variable Declarations"
Dim dept As New Department()
Dim safetySegment As String = ""
Dim unitsDefective As Double
Dim numDefects As Double
Dim displayString As String = ""
Dim strDept As String = ""
Dim shift As String = ""
Dim Prod_Cell As String = ""
Dim Prod_Line As String = ""
Dim ICNT As String = ""
Dim Begining_Date As String = ""
Dim Ending_Date As String = ""
Dim qual As New Quality()
Dim strOutToProgram As String
Dim strOuttoDisplay As String = ""
Dim Display As New Scoreboard()

display setting variables
Dim STX As String
Dim ETX As String
Dim extraChars As String
Dim Com_Port As Int16
Dim BaudRate As Double
Dim Parity As String
Dim Databit As Int16
Dim StopBit As Int16
#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Me.SqlDataAdapter1.Fill(InjuryData1)
Me.txtRunTime.Text = Now
Me.InitializeTimer1()
Me.InitializeTimer2()

End Sub

Private Sub InitializeTimer1()
timer1 controls the frequency of the display data
current setting call to database every 60 seconds
Me.Timer1.Interval = 60000
Me.Timer1.Enabled = True
Me.Timer1.Start()

End Sub

Private Sub InitializeTimer2()
timer2 controls the frequency of refresh of safety data
current setting refreshes safety days every 60 seconds.
Me.Timer2.Interval = 60000
Me.Timer2.Enabled = True
Me.Timer2.Start()

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.TextBox1.Text = ""
strOutToProgram = ""
Dim intSafetyID As Int16
Dim dtDateLastInjury As Date
Dim icimReader1 As OleDbDataReader
Dim icimReader2 As OleDbDataReader
qual.openConnection()

If TimeOfDay >= #5:00:00 AM# And TimeOfDay <= #3:30:00 PM# Then
shift = "D"
Else
shift = "S"
End If

Dim Reader As SqlDataReader = dept.GetCurrentDepts(Today, shift)

While Reader.Read
--------------------Safety Segment ---------------------------------
intSafetyID = Reader.Item("SafetyID")
strDept = Reader.Item("DLID")
for each item in the sqlDataReader, get the # of days since last injury compared to todays system date
Dim rowFoundRow As DataRow = Me.InjuryData1.DeptInjury.Rows.Find(intSafetyID)
If Not (rowFoundRow Is Nothing) Then
dtDateLastInjury = CType(rowFoundRow("datelastinjury"), String)
safetySegment = CType(DateDiff(DateInterval.Day, dtDateLastInjury, Now), String)
Else
this happens if no match is found in the safety/injury table
safetySegment = "0"
End If

-------------------------# of Defective Units Segment -----------
get shift start and end times

Begining_Date = dept.GetShiftStart(shift)
Ending_Date = dept.GetShiftEnd(shift)
ICNT = Reader.Item("INVC")
Prod_Cell = Reader.Item("Department")
Prod_Line = Reader.Item("Line")

now call the Quality class and pass the shiftStart, ShiftEnd, INVC,DeptCode,and Line
to a method that will return the number of defective units within these restrictions
from oracle

icimReader1 = qual.GetDefectiveUnits(ICNT, Prod_Cell, Prod_Line, Begining_Date, Ending_Date)

While icimReader1.Read
unitsDefective = icimReader1.Item(0)
End While

icimReader1.Close()


---------------------# of Defects Segment -----------------------
call the quality class again
icimReader2 = qual.GetNumDefects(ICNT, Prod_Cell, Prod_Line, Begining_Date, Ending_Date)
While icimReader2.Read
numDefects = icimReader2.Item(0)
End While

close icimReader object so the connection is freed up
icimReader2.Close()

this is the string for display purposes only
buildString(strDept + " " + CType(safetySegment, String) + " " + CType(numDefects, String) + " " + CType(unitsDefective, String))
---------send to the displays ---------------------------
UpdateComSettings(strDept)
SendToDisplay(CType(safetySegment, String), CType(numDefects, String), CType(unitsDefective, String))
End While
cleanup
Reader.Close()
Me.qual.closeConnection()
Me.dept.CloseConnection()
Me.txtQuality.Text = Now

End Sub

Public Sub UpdateComSettings(ByVal DLID As String)
this subroutine gets and sets the com port info for each display
Dim Reader As SqlDataReader = Display.GetComSettings(DLID)
While Reader.Read
STX = Reader.Item("STX")
ETX = Reader.Item("ETX")
extraChars = Reader.Item("extraChars")
Com_Port = Reader.Item("Com_Port")
BaudRate = Reader.Item("BaudRate")
Parity = Reader.Item("Parity")
Databit = Reader.Item("DataBit")
StopBit = Reader.Item("StopBit")
End While

Reader.Close()
Display.CloseDBConnection()

Me.ComControl.Settings = CType(BaudRate, String) + "," + CType(Parity, String) + "," + CType(Databit, String) + "," + CType(StopBit, String)
Me.ComControl.CommPort = Com_Port

End Sub

Public Sub SendToDisplay(ByVal injuryDays As String, ByVal numDefects As String, ByVal NumDefective As String)
pass the DLID to the SetComSettings sub and get the settings for the com control
Dim seg1 As String = ""
Dim seg2 As String = ""
Dim seg3 As String = ""
Dim output As String = ""

adjust for the length of the first segment
If Len(injuryDays) = 4 Then seg1 = injuryDays
If Len(injuryDays) = 3 Then seg1 = " " + injuryDays
If Len(injuryDays) = 2 Then seg1 = " " + injuryDays
If Len(injuryDays) = 1 Then seg1 = " " + injuryDays

adjust for the length of the second segment
If Len(numDefects) = 4 Then seg2 = numDefects
If Len(numDefects) = 3 Then seg2 = " " + numDefects
If Len(numDefects) = 2 Then seg2 = " " + numDefects
If Len(numDefects) = 1 Then seg2 = " " + numDefects

adjust for the length of the third segment
If Len(NumDefective) = 4 Then seg3 = NumDefective
If Len(NumDefective) = 3 Then seg3 = " " + NumDefective
If Len(NumDefective) = 2 Then seg3 = " " + NumDefective
If Len(NumDefective) = 1 Then seg3 = " " + NumDefective
====================
open com port
If Me.ComControl.PortOpen = False Then
Me.ComControl.PortOpen = True
End If

create output string
output = Chr(STX) & extraChars & seg1 & seg2 & seg3 & Chr(ETX)

output to display via com port
If Me.ComControl.PortOpen = True Then
Me.ComControl.Output = output
Me.ComControl.PortOpen = False
End If

End Sub

Public Sub buildString(ByVal input As String)
console display output string
strOutToProgram += input & vbCrLf
Me.TextBox1.Text = strOutToProgram
End Sub

Private Sub Timer2_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Me.InjuryGrid.DataSource = Nothing
Me.SqlDataAdapter1.Fill(InjuryData1)
Me.txtInjury.Text = Now
Me.InjuryGrid.DataSource = Me.InjuryData1.DeptInjury
End Sub
 
I have been reading a lot and found some information on using APIs instead of the mscomm control. I am looking into going this route.
 
Back
Top