OPC Writes with multiple items and VT_BSTR data

M

Thread Starter

Michael Dannhardt

I am seeing an interesting problem I wonder if anyone can explain. I have tried this with with several servers and several clients from various vendors and all show the same behaviour.

I configure an OPC server with at least two tags.

I select an OPC client that can send multiple items in a write operation at once. Many clients send only individual write items/data, one at a time.

I configure the client with a group and add two items for the two server tags. Add the items as VT_BSTR. (It does seem to matter whether tags in the Server are VT_BSTR or not.)

Now set the data to send to two different VT_BSTR values and trigger the operation. 9 times out of 10 the VT_BSTR data received at the server is the same for both items. (I say 9 out of 10 because I think I saw it work once or twice but I am not sure with the clients I am using that they always send both peices of data - they may only send one's changed? At any rate it happens consistently).

I only see this happen if all data is VT_BSTR.

Can anyone help me explain this or tell me that they do not see this? Maybe its a OS configuration problem?

Thanks for any suggestions/assistance.
Mike
-----------------------------------------------------------------------------
From: Michael Dannhardt, DASTEC Corporation
Address: 457A Carlisle Drive;
Herndon, VA 20170 USA
Tel: 703 709 0515
Fax: 703 709 0985
E-mail: [email protected]
Web: http://www.dastec.com
-----------------------------------------------------------------------------
 
W

Wallinius Mattias

There is a bug either in the server or the client but most probably in the server and the server can not handle the C array of BSTRS. Probably they
don't handle BSTRS the correct way.
/Mattias
 
M

Michael Dannhardt

Thank you for the info.

I don;t think that it is a bug in the client or the server as I have tried several of each from various sources.

I first ran into the problem with a server I am writing and thought I had made a programming error and so began to dig into the problem
deeper. My debugging showed that the data received at the interface was incorrect, before any of my code really had a chance to operate on the data..

I am hoping someone can try this themselves and let me know one way or the other: it worked for them or they see the same error.

BTW: The data is being passed as individual items, in an array yes but not a data type array just to clarify.

Mike

 
S

Scott Cornwall

Michael,
We do not experience this problem with OPC clients and servers we have developed.
We suspect a bug in the client. You say you have used multiple servers and multiple clients from different sources, that really only leaves DCOM -
unlikely and we do not find the problem.
Another consideration, we do not use any of the OPC server or client toolkits as a basis for our products. Were these clients or servers you
tested all generated from the same toolkit ?

Regards,
Scott Cornwall
_________________
www.sentech.co.nz
 
W

Wallinius Mattias

I will verify what you say, what this indicates is a marshalling problem. If you choose to transfer data as an array the type will be a SAFE ARRAY of the type of data in this case BSTR's, but when you transfer multiple items they will be transferred as an C style array of data. These two types are marshaled differently to say the least.
/Mattias
 
S

Scott Cornwall

As far as I understand, the items are not arrays of strings but two separate string items. These would be encapsulated into two separate variants on the client side (in the pItemValues array of variants). The problem appears to occur on OPC writes - in that case there is no marshalling or un-marshalling done directly by the client (neither for OPC DA Spec 1 nor OPC DA Spec 2),
and only the opcproxy.dll might come in-between the client and server. It would be worthwhile to check for the correct version of the proxy.
Also check for the latest version of DCOM95/98 if Windows 95/98 is being used. This should be done regardless of this problem due to memory leaks in
the older versions of DCOM 95/98.

Scott Cornwall
_________________
www.sentech.co.nz
 
A

Alex Pavloff

Hello list:

I do a lot of COM programming, so let me provide my insight. The Write methods for both IOPCAsycIO and IOPCSyncIO take as their 4th parameter a VARIANT*. A Microsoft VARIANT can be any type... including an array. So there are a couple way to pass multiple BSTR around. You can have an array of multiple variants, each containing one BSTR, or you can have one VARIANT,
containing an array of multiple BSTR.

I would suspect the BSTRs are being jammed into the VARIANT* the wrong way.
It's probably the clients fault.

Alex Pavloff
Software Engineer
Eason Technology
 
W

Wallinius Mattias

What? Please explain to me the role of the proxy /stub if it wasn't for marshalling. I have done some tests and it's a bug in either the server or the client. Check the toolkits as someone earlier suggested.
/Mattias
 
X
Hello Alex:

I have some pbs with the Write methods IOPCSyncIO.
The 4th parameter is a VARIANT*, and I don't manage to write an array of variant. I use a single ItemHandle, but it represents multiple items (example : TSX_57!%MW100:10).
I think that the solution is to give to the Write method a variant wich contain a SafeArray, but I don't know how to do that...
Could you help me please?
I work on the Simple Delphi OPC Client.

Best Regards.
Xavier Dano
SEA PRODUCTIQUE
 
Top