LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

COM/ActiveX Register Event Callback Problem

Hi nyc, Thanks fot the reply.

 

I think only readDescription() function is defined between readChannelNumber() and readLowPassFilterType() functions which doesn't matter from data structure point of view.  In the line 200 of the TestClientDialog.h file, the structure is defined like the image I posted before.

As for the initialization, I tried that CmdID set to zero, but I still have some problems!

0 Kudos
Message 11 of 22
(502 Views)

Hi Nathan,

 

I've never heard of "DSNewPtr" before.  This could help a lot.  I'm gonna study that and try it in my code.  I will get back to you if I have any questions regarding DSNewPtr.

 

I have some documentations and C++ example which are attached here.  Page 72 of the pdf file talks about USBPxxS1COM programming and the 4 steps for initializing the COM object.  Also, "TestClientDialog.h" file in the example explains in details how this is done...

 

Can you please check one thing in particular for me: The 4 necessary steps to control this ActiveX/COM object.  Do I take these steps by the following code:

 

Alligator04.png

Download All
0 Kudos
Message 12 of 22
(501 Views)

OK, after looking at the code... the Variant parameter isn't what you described at all. The USBPxxPARAMETERS structure is part of the example code, not part of the library - you don't need it at all. The In and Out Variant parameters are, in fact, standard Microsoft Variants as described here: http://msdn.microsoft.com/en-us/library/cc237870.aspx. That makes things both more and less complicated. As far as I know, a LabVIEW Variant is NOT the same thing as an ActiveX variant, so you can't use LabVIEW's native variant functions. There might be some clever way to force coercion between the two, since LabVIEW can do that natively, but I have no idea how you would do this.

 

You would need to allocate space yourself for the size of the complicated Variant type, pass that pointer, then parse out the correct bytes, copy them to a LabVIEW wire, and possibly reverse the byte order (because LabVIEW and Windows don't agree on endian-ness, for historical reasons). Setting data for the In parameter requires doing all this the other way round. Basically it would be a lot of work and requires a good understanding of C.

 

In addition to all that, you would need to sort out the startup/initialization process. We're beyond my knowledge of ActiveX programming here (and I'm not completely convinced they know what they're doing either - who puts actual code in a header file?). It like maybe this was designed to be a control embedded in the front panel? Assuming the DLL is properly registered with regsrvr, try adding an ActiveX container to your front panel, then right-click, choose Insert ActiveX Object... and see if there's an object in there somewhere that looks like it's part of the Alligator library. If so, use that, and see if you can execute the initialize method on it.

0 Kudos
Message 13 of 22
(494 Views)

Alligator people told me that I have to define the structure like that.  I can try and manipulate their code to check if it works with different type of data structure.

 

I had tried ActiveX Container before, but no luck.  Here’s what I do:

1. Insert ActiveX Container in the Front Panel.

2. Right click on the container and select Insert ActiveX Object.

3. I’m supposed to select the object from the list, but it’s not available!  So, from the top of the window, I select Create Object From File, and I browse and select “USBPxxS1COM.dll”.

Here’s what I get on front panel and block diagram, and when I put property node, invoke node, or register event callback, there’s nothing to work with.

 

Alligator05.png

 

Thanks a lot for all your help.

0 Kudos
Message 14 of 22
(483 Views)

@Rooz wrote:

Hi nyc, Thanks fot the reply.

 

I think only readDescription() function is defined between readChannelNumber() and readLowPassFilterType() functions which doesn't matter from data structure point of view.  In the line 200 of the TestClientDialog.h file, the structure is defined like the image I posted before.

As for the initialization, I tried that CmdID set to zero, but I still have some problems!


No. You need to be looking at line 891 of TestClientDialog.h. Line 200 is *not* what you need. You are not understanding it.

 

The CmdID=0 would be in your Callback.vi once you get a handle.

 

 

Frankly, I am not sure why you chose this company. Did they expect only C++ experts to be able to use their product?

It is ridiculous. No VB.NET or even C# example.

 

 

0 Kudos
Message 15 of 22
(480 Views)

@nyc_(is_out_of_here) wrote:

No. You need to be looking at line 891 of TestClientDialog.h. Line 200 is *not* what you need. You are not understanding it.

 

The CmdID=0 would be in your Callback.vi once you get a handle.


I don't think this is right... it looks to me like during initialization, it calls USBPxxS1Command with the Handle and Command both set to 0, which suggests that you don't need a handle to do the initialization.

 

I notice that the documentation mentions HIDAgentXcontrol1.ocx, which is an ActiveX control that you might be able to embed on your front panel, although when I tried it told me it's not licensed.

 

Unfortunately we've reached the limit of where I can be helpful here.

0 Kudos
Message 17 of 22
(459 Views)

@nathand wrote:

@nyc_(is_out_of_here) wrote:

No. You need to be looking at line 891 of TestClientDialog.h. Line 200 is *not* what you need. You are not understanding it.

 

The CmdID=0 would be in your Callback.vi once you get a handle.


I don't think this is right... it looks to me like during initialization, it calls USBPxxS1Command with the Handle and Command both set to 0, which suggests that you don't need a handle to do the initialization.

 

I notice that the documentation mentions HIDAgentXcontrol1.ocx, which is an ActiveX control that you might be able to embed on your front panel, although when I tried it told me it's not licensed.

 

Unfortunately we've reached the limit of where I can be helpful here.


Yes, both the Handle=0 and the CmdID=0, then once you get the handle it looks like, you need to initialize again, per page 13-12 of the manual section 13.4.1.2.1

 

Horrible documentation for a piece of test equipment to be used by non-C++ programmers. It would not have been my first choice.

 

 

The error message about HIDAgentXcontrol1.ocx may be fixable, http://digital.ni.com/public.nsf/allkb/FF6AB0B70928F81E86257077007ECDFF

but appears to require VB6.

0 Kudos
Message 18 of 22
(457 Views)

HIDAgentXcontrol1.ocx is a USB transport layer, and as long as it's registered with the OS we don't have to touch it.  Although, I have tried different methods to use it in the program, but I couldn’t. I also tried that with an ActiveX container, and I got the same error. Even when I installed the VB runtime and other things, it didn’t work. I also tried Automation Open, but what I get from Invoke and Property Node don’t make any sense!

 

I also tried to encapsulate their example in a DLL and use the Call Library Function Node, but I get this error (just in LabVIEW not in VC++).  I'm not sure if LabVIEW is compatible with ATL.

 

Alligator06.png 

 

0 Kudos
Message 19 of 22
(448 Views)

Personally I think you were on the right track with the VIs you had.

You simply need to flesh out the callback VI with Invokes.

The unknown is what to do about the variant pointers.

 

0 Kudos
Message 20 of 22
(445 Views)