Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: DataCollect access

DataCollect access 6 years 3 months ago #9457

  • grindy
  • grindy's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 44
  • Karma: 0
Hi all,

I need to get several strings, written by operator, in a DataAritm.
I used GetData to Get string value stored in Sv obj,and then a DataCollector connected to the DArithm.
Browsing the forum I found some ideas to access the string, but I miss something.

Code in the DataArithm:
classdef Da3 DataCollect;
classdef Da4 DpCollect;

pwr_sClass_Sv * Buf; 
Buf = ((pwr_sClass_Sv *)(Da3->DataP[2].Ptr))->ActualValue;
...
    fprintf(MyFile,"ID:%s;%d;%d;%d;%d\n",Buf,I5,Da4->Dp[0],Da4->Dp[1],Da4->Dp[2]);

This generate the following warning:

warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘struct pwr_sClass_Sv *’ [-Wformat]

What kind of class should I use for Buf?
Thanks in advance
The administrator has disabled public write access.

DataCollect access 6 years 3 months ago #9460

  • claes
  • claes's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 3177
  • Thank you received: 502
  • Karma: 133
Hi grindy,

It should be a char pointer.

/Claes
The administrator has disabled public write access.

DataCollect access 6 years 2 months ago #9472

  • grindy
  • grindy's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 44
  • Karma: 0
Hi Claes,

thank you, I understood the error message, but I don't know how to fix the code.
I don't know which pwr_cass i can use instead of pwr_sClass_Sv.
Can you help me?
The administrator has disabled public write access.

DataCollect access 6 years 2 months ago #9473

  • claes
  • claes's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 3177
  • Thank you received: 502
  • Karma: 133
Hi grindy,

Sv.ActualValue is an array of char, so Buf should be declared as a char * instead of pwr_sClass_Sv *.

char *Buf; 
Buf = ((pwr_sClass_Sv *)(Da3->DataP[2].Ptr))->ActualValue;

/Claes
Last Edit: 6 years 2 months ago by claes.
The administrator has disabled public write access.
  • Page:
  • 1
Time to create page: 8.587 seconds