Hi,
I have a VB6 program controller a temperature controller.
Here is the connection: Serial Comm2 --- RS232 --- RS485 --- temperature controller.
Every time I close the program, it sends a STOP signal to the temperature controller, then close the program. However, after the program is closed, and waits for a couple of seconds, the computer ties up. I can still operate it but super slow. When I open another program to use the same comm port, the computer is back to be normal.
So I am thinking if there is something left in the Comm port or the RS-232 buffer that I need to clear it up. But how can I do that? Any ideas? Please see additional information below.
In the VB program I have:
MSComm control properties:
Handshaking - comNone
InBufferSize - 1024
OutBufferSize - 512
InputLen - 0
InputMode - 0 - comInputModeText
ParityReplace - ?
RThreshold - 0
RTSEnalbe - False
Settings - 19200,n,8,1
SThreshold - 0
Coding:
Open Port:
MSComm1.CommPort = 2
MSComm1.Handshaking = comRTS
MSComm1.Settings = "19200,N,8,1"
MSComm1.InputMode = comInputModeText
MSComm1.RThreshold = 1
MSComm1.InputLen = 1
MSComm1.PortOpen = True
=======================================================
MSComm1_OnComm
Dim sBuffer As String
Dim sHeader As String
Dim sTemp As String
Dim iCounter As Integer
Dim fTemp As Single
Select Case MSComm1.CommEvent
' Handle each event or error by placing
Case comEvReceive ' Received RThreshold # of chars.
sBuffer = MSComm1.Input
If sBuffer = Chr$(3) Then 'we have found the end of the line
sHeader = Right$(f_strInString, 22)
If Left$(sHeader, 14) = "01000001010000" Then 'we have the upper temperature reading
fTemp = Val("&h" & Mid$(sHeader, 15, 8))
g_sUpperTemp = fTemp / 10
If Not bMetric Then fTemp = (fTemp / 10 * 1.8 + 32) * 10
frmSeal.lblResults(1).Caption = Format(Val(fTemp) / 10, g_strTempFormat)
ElseIf Left$(sHeader, 14) = "02000001010000" Then 'we have the lower temperature reading
fTemp = Val("&h" & Mid$(sHeader, 15, 8))
g_sLowerTemp = fTemp / 10
If Not bMetric Then fTemp = (fTemp / 10 * 1.8 + 32) * 10
frmSeal.lblResults(2).Caption = Format(Val(fTemp) / 10, g_strTempFormat)
End If
f_strInString = ""
Else ' we are not at the end so keep building the string
f_strInString = f_strInString & sBuffer
End If
End Select
===========================================================
Close program
OutString = Chr$(2) & "01000" 'Command Frame
OutString = OutString & "30050101" & Chr$(3) 'send the STOP Command to the temperature controllers
OutString = OutString & Chr$(CalcBCC(OutString))
If Not bNoComms Then MSComm1.output = OutString
MSComm1.PortOpen = False
Unload Me
End
Please help ASAP 'cause I need to fix it by tomorrow.
I have a VB6 program controller a temperature controller.
Here is the connection: Serial Comm2 --- RS232 --- RS485 --- temperature controller.
Every time I close the program, it sends a STOP signal to the temperature controller, then close the program. However, after the program is closed, and waits for a couple of seconds, the computer ties up. I can still operate it but super slow. When I open another program to use the same comm port, the computer is back to be normal.
So I am thinking if there is something left in the Comm port or the RS-232 buffer that I need to clear it up. But how can I do that? Any ideas? Please see additional information below.
In the VB program I have:
MSComm control properties:
Handshaking - comNone
InBufferSize - 1024
OutBufferSize - 512
InputLen - 0
InputMode - 0 - comInputModeText
ParityReplace - ?
RThreshold - 0
RTSEnalbe - False
Settings - 19200,n,8,1
SThreshold - 0
Coding:
Open Port:
MSComm1.CommPort = 2
MSComm1.Handshaking = comRTS
MSComm1.Settings = "19200,N,8,1"
MSComm1.InputMode = comInputModeText
MSComm1.RThreshold = 1
MSComm1.InputLen = 1
MSComm1.PortOpen = True
=======================================================
MSComm1_OnComm
Dim sBuffer As String
Dim sHeader As String
Dim sTemp As String
Dim iCounter As Integer
Dim fTemp As Single
Select Case MSComm1.CommEvent
' Handle each event or error by placing
Case comEvReceive ' Received RThreshold # of chars.
sBuffer = MSComm1.Input
If sBuffer = Chr$(3) Then 'we have found the end of the line
sHeader = Right$(f_strInString, 22)
If Left$(sHeader, 14) = "01000001010000" Then 'we have the upper temperature reading
fTemp = Val("&h" & Mid$(sHeader, 15, 8))
g_sUpperTemp = fTemp / 10
If Not bMetric Then fTemp = (fTemp / 10 * 1.8 + 32) * 10
frmSeal.lblResults(1).Caption = Format(Val(fTemp) / 10, g_strTempFormat)
ElseIf Left$(sHeader, 14) = "02000001010000" Then 'we have the lower temperature reading
fTemp = Val("&h" & Mid$(sHeader, 15, 8))
g_sLowerTemp = fTemp / 10
If Not bMetric Then fTemp = (fTemp / 10 * 1.8 + 32) * 10
frmSeal.lblResults(2).Caption = Format(Val(fTemp) / 10, g_strTempFormat)
End If
f_strInString = ""
Else ' we are not at the end so keep building the string
f_strInString = f_strInString & sBuffer
End If
End Select
===========================================================
Close program
OutString = Chr$(2) & "01000" 'Command Frame
OutString = OutString & "30050101" & Chr$(3) 'send the STOP Command to the temperature controllers
OutString = OutString & Chr$(CalcBCC(OutString))
If Not bNoComms Then MSComm1.output = OutString
MSComm1.PortOpen = False
Unload Me
End
Please help ASAP 'cause I need to fix it by tomorrow.