E_FAIL when reading OPC-DA Tag|Classic OPC: DA, A&E, HDA, XML-DA, etc.|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
E_FAIL when reading OPC-DA Tag
Avatar
Miguel Cid
Member
Members
Forum Posts: 6
Member Since:
05/20/2014
sp_UserOfflineSmall Offline
1
10/02/2020 - 04:35
sp_Permalink sp_Print

Hi All,

I am using OPC .NET Api in my application develped under .NET Framework.

The OPC server I am using is Simatic .NET V16.

The OPC communication works fine, tested with OPC Scout.

I can write tags through PLC with no problem using the Write method:

Opc.IdentifiedResult[] resultsW = ServerOPC.Write(itemsW);

 

But when I try to read the same tags.

Opc.Da.ItemValueResult[] resultS = ServerOPC.Read(items);

 

I have the exception :

E_FAIL

IOPCItemIO.Read

 

Any idea?

Thanks in advance.

Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
10/02/2020 - 06:41
sp_Permalink sp_Print

If there is an exception that means there is a problem with the call rather than the item.

Try the async version of the Read interface.

Avatar
Miguel Cid
Member
Members
Forum Posts: 6
Member Since:
05/20/2014
sp_UserOfflineSmall Offline
3
10/02/2020 - 07:02
sp_Permalink sp_Print

Hi Randy.

Never done it before.

How to try the async version?

Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
4
10/03/2020 - 02:37
sp_Permalink sp_Print
/// <summary>
/// Begins an asynchronous read operation for a set of items.
/// </summary>
/// <param name="items">The set of items to read (must include the server handle).</param>
/// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
/// <param name="callback">A delegate used to receive notifications when the request completes.</param>
/// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
/// <returns>A set of results containing any errors encountered when the server validated the items.</returns>
IdentifiedResult[] Read(
    Item[] items,
    object requestHandle,
    ReadCompleteEventHandler callback,
    out IRequest request);
Avatar
Miguel Cid
Member
Members
Forum Posts: 6
Member Since:
05/20/2014
sp_UserOfflineSmall Offline
5
10/06/2020 - 01:42
sp_Permalink sp_Print

Thank you for your help Randy.

I am currently using groups to read the data.

Siemens has no explanation for this behavior...they say there is no difference between V14 and V16.

What I've been reading is that the IOPCItemIO interface is implemented in all DA3.0 OPC Servers, but apparently there is something wrong in Simatic .NET V16, or I am doing something wrong in my installation...

This error made me take a look to the documentation I found in the web and in it it said that it's better to use groups in terms of efficiency.

For those that run into this error, I hope it helps.

This is what I am doing

//Create Group
Opc.Da.Subscription GroupSync; // Group for Read PLC Tags
Opc.Da.SubscriptionState GroupStateSync = new Opc.Da.SubscriptionState(); // Sync

GroupStateSync.Name = "GroupSync";
GroupStateSync.Active = false;
GroupSync = (Opc.Da.Subscription)ServerOPC.CreateSubscription(GroupStateSync);

//Define Items to Read

//Opc.Da.Item[] items = new Opc.Da.Item[Number of Items]

GroupSync.AddItems(items);

 

//Read items when

Opc.Da.ItemValueResult[] results = GroupSync.Read(GroupSync.Items);

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 41
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1435
Posts: 4855