glideratio
Member
Hi all,
has anyone used MSCOMM in VB6 with OPC ?
I have a serious issue with KEPServerEX4.0, VB6 and MSCOMM (Microsoft Comm Control 6.0).
I'm using an MSCOMM1 in my application.
The task is to open a COM1 port in the event of OPC tag change.
Now, the problem is when I do it like that the COM port doesn't open. The program goes to debug mode.
I wrote a function to test whether the port is open or closed and the program says that the port is open and closed at the same time.
If I use just a regular command button on the form to open the COM1 port it works fine but it doesn't work if COM1 port opening Sub is triggered by an OPC tag.
I'm wondering is this a MicrosoftVB6 or Kepware or OPC bug ?
The code is as follows:
----------MSCOMM Sub-----------
Public Sub SF401_BalanceOpenPort()
MSComm1.CommPort = 1
' 9600 baud, no parity, 8 data, and 1 stop bit.
MSComm1.Settings = "9600,N,8,1"
' Tell the control to read entire buffer when Input
' is used.
MSComm1.InputLen = 0
' Open the port.
MSComm1.PortOpen = True
End Sub
---------------------------------
......
---------------------------------
Sub ConnectedGroup_DataChange(ByVal TransactionID As Long, ByVal NumItems As Long, _
ClientHandles() As Long, ItemValues() As Variant, Qualities() As Long, TimeStamps() As Date) 'OPC Data change sub that updates the values
Dim X As Integer
For X = 1 To NumItems
Select Case ClientHandles(X)
Case 2
If ItemValues(X) = 20 Then
Call SF401_BalanceOpenPort 'this is where port opening sub is activated
End If
End Select
Next X
End Sub
---------------------------------
Can someone test this on his PC ?
Thank you
regards
has anyone used MSCOMM in VB6 with OPC ?
I have a serious issue with KEPServerEX4.0, VB6 and MSCOMM (Microsoft Comm Control 6.0).
I'm using an MSCOMM1 in my application.
The task is to open a COM1 port in the event of OPC tag change.
Now, the problem is when I do it like that the COM port doesn't open. The program goes to debug mode.
I wrote a function to test whether the port is open or closed and the program says that the port is open and closed at the same time.
If I use just a regular command button on the form to open the COM1 port it works fine but it doesn't work if COM1 port opening Sub is triggered by an OPC tag.
I'm wondering is this a MicrosoftVB6 or Kepware or OPC bug ?
The code is as follows:
----------MSCOMM Sub-----------
Public Sub SF401_BalanceOpenPort()
MSComm1.CommPort = 1
' 9600 baud, no parity, 8 data, and 1 stop bit.
MSComm1.Settings = "9600,N,8,1"
' Tell the control to read entire buffer when Input
' is used.
MSComm1.InputLen = 0
' Open the port.
MSComm1.PortOpen = True
End Sub
---------------------------------
......
---------------------------------
Sub ConnectedGroup_DataChange(ByVal TransactionID As Long, ByVal NumItems As Long, _
ClientHandles() As Long, ItemValues() As Variant, Qualities() As Long, TimeStamps() As Date) 'OPC Data change sub that updates the values
Dim X As Integer
For X = 1 To NumItems
Select Case ClientHandles(X)
Case 2
If ItemValues(X) = 20 Then
Call SF401_BalanceOpenPort 'this is where port opening sub is activated
End If
End Select
Next X
End Sub
---------------------------------
Can someone test this on his PC ?
Thank you
regards