LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

OPC Modbus, multiple address

I'm trying to connect my application to a Modbus Slave via serial connection, using OPC server. I can read only the first record, but I can't read multiple consecutive address from the slave.
This is the code I use to get data:
 
DS_Update (handle);
DS_GetDataType (handle, &type, &size1, &size2);
//   type = 105 (double)
//   size1 = 0  (why?)

value = malloc (10 * sizeof (double));
DS_GetDataValue (handle, CAVT_DOUBLE | CAVT_ARRAY, value, 10 *sizeof(double), &dim, 0);
//  dim = 0  (wrong)
 
If I use CAVT_DOUBLE I can read the first address.
Thanks, 
Pietro
0 Kudos
Message 1 of 2
(2,946 Views)

Hi,

this is a know issue with the Datasocket API for CVI 7.1 or earlier and it was fixed in CVI 8.0

Attached here you can find an example that will connect to an array of double and plot it on a graph in CVI. This example is connecting to the DS Item in Polling mode. In CVI 8.0 this works fine, while in CVI 7.x it was not working, as the dimension of data returned by DS_GetDataType() was =0, as you indicated in your post.

A workaround to this is found in the example, an it is represented by line 73 --> dim1=20; This of course assumes you know the dimension of the array you are going to get data from, but it allows to make things work.

AlessioD

0 Kudos
Message 2 of 2
(2,931 Views)