Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

OnError Problem with CWGPIB in cwinstr.ocx

I am having a problem when using a CWGPIB object in an ActiveX exe.  I am not using a form so I have a reference to the object defined and instanced as follows:
 
Private WithEvents GPIBPort as CWGPIB
 
Set GPIBPort = New CWGPIB
 
I have two events defined as follows:
    Private Sub GPIBPort_DataReady(ByVal taskNumber As Integer, data As Variant)
        Dim ReturnVals() As String
       
        GPIBData = data
        ReturnVals() = Split(GPIBData, ",")
       
        mvarValue = CDbl(ReturnVals(2))
        ComServer.FireRecdEvent Key, CStr(data) & vbCrLf
        ComServer.FireDeviceEvent Key, KEITHLEY_VALUE
        If GPIBSendReplyToPLC Then mvarPort_PortEvent Key, CStr(data)
        GPIBBusy = False
        GPIBSendReplyToPLC = False
    End Sub
   
    ' If there is an error, put up a message box with the error message
    Private Sub GPIBPort_OnError(ByVal ErrorCode As Long, ByVal ErrMsg As String)
        'set error codes here
        mvarErrCode = ErrorCode
        mvarErrDesc = ErrMsg
        ComServer.FireRecdEvent Key, "GPIB Error Event, Error Code-" & CStr(ErrorCode) & ", Desc-" & ErrMsg & vbCrLf
        ComServer.FireDeviceEvent Key, KEITHLEY_ERROR
        GPIBBusy = False
        GPIBSendReplyToPLC = False
    End Sub
Both events do some processing and then fire two events out from my ActiveX exe to its clients.
 
The GPIBPort events fire predictably whenever there is a reading or an error.  My events that are fired out to my clients fom the GPIBPort_DataReady event work perfectly, but my events fired from the GPIBPort_OnError event are never received by my clients.  When I debug the firing of my events from either of the GPIBPort events they do the same thing as far as I can see.
 
Any idea would be greatly appreciated!
 
Dave
0 Kudos
Message 1 of 4
(7,953 Views)
Hi Dave,

This is interesting. You say that the events fire predictably. How did you verify this? Your event calls look correct, so I see no reason that the events in your error event shouldn't fire.  You could try firing the same events in both cases and see if you register the events when the error event fires.

Let us know if you've made any headway or if it's still giving you problems.

Regards,
Matt S.

LabVIEW Integration Engineer with experience in LabVIEW Real-Time, LabVIEW FPGA, DAQ, Machine Vision, as well as C/C++. CLAD, working on CLD and CLA.
0 Kudos
Message 2 of 4
(7,936 Views)
I have no clue what's going on yet.

Basically my archiecture is as follows:

ClientExe --> ActiveXExe --> cwinst.ocx-->GPIB Meter

If I put breakpoints on the "ComServer.FireRecdEvent" lines in both the GPIBPort_DataReady and GPIBPort_OnError event handlers they always get hit appropriately depending on the state of the information returned by the meter.

If I step through the execution from these breakpoints all the way out of my ActiveXExe from either GPIBPort event handler it works perfectly.  The ecexution path is exactly the same once they each call ComServer.FireRecdEvent.  The problem is events that are raised from GPIBPort_OnError are never received by the ClientExe while events that are raised from GPIBPort_DataReady are always received by the ClientExe. The events raised in my program that originated from the OnError event seem to be lost somewhere between the ActiveXExe and the ClientExe.

I have no clue what else to try, but I suspect it must be a VB problem of some kind, Maybe something to do with the event name "OnError".

Dave
0 Kudos
Message 3 of 4
(7,927 Views)
Hi Dave,

This does indeed look like you may be having some VB linking problems. Again, I'm no master of VB and don't know how much help I can be in this situation. Hopefully someone else here in the community will have some input into this for you. If you come to a point where you're having any driver issues or anything, definitely post that here as well. I'll be able to provide worlds more input in that realm.

Regards,
Matt S.

LabVIEW Integration Engineer with experience in LabVIEW Real-Time, LabVIEW FPGA, DAQ, Machine Vision, as well as C/C++. CLAD, working on CLD and CLA.
0 Kudos
Message 4 of 4
(7,908 Views)