Home > Software engineering >  Opc client AddItems return values for s_false
Opc client AddItems return values for s_false

Time:10-27

Add a server and group has any mistake

Errors occur in OPCITEMDEF szItem

M_pItems=new OPCITEMDEF [dwCount];

Read all need to read from the CSV file szItem
 
M_pItems [I] szAccessPath=L "";
M_pItems [I] szItemID=T2OLE (strItemID. GetBuffer (0));
//m_pItems [I] szItemID=L "SAMPLE. XXX. F_CV";
M_pItems [I] bActive=TRUE;
M_pItems [I] hClient=I;
M_pItems [I] dwBlobSize=0;
M_pItems [I] pBlob=NULL;
M_pItems [I] vtRequestedDataType=VT_R4;
M_pItems [I] wReserved=0;



If use m_pItems [I] szItemID=T2OLE (strItemID. GetBuffer (0)); In AddItems would return s_false
If fill m_pItems [I] szItemID=L "SAMPLE. XXX. F_CV"; , returns s_ok

After debugging, can guarantee strItemID=SAMPLE. XXX. F_CV

Also tried to use MultiByteToWideChar, the same result

Please expert help, take a look at what is the reason, thank you,

CodePudding user response:

No body?

CodePudding user response:

P_Items [0]. SzAccessPath=L "";
P_Items [0]. SzItemID=L "[sfc_text] text_opc_real";//REAL
P_Items [0]. BActive=TRUE;
P_Items [0]. HClient=1;//identity ID, different ITEM is not the same as
P_Items [0]. DwBlobSize=0;
P_Items [0]. PBlob=NULL;
P_Items [0]. VtRequestedDataType=5;//data type 5 to REAL



I write synchronization, even is AB - PLC, asynchronous can't write, the building Lord will write?? consult

CodePudding user response:

refer to the second floor lovexin109 response:
p_Items [0]. SzAccessPath=L "";
P_Items [0]. SzItemID=L "[sfc_text] text_opc_real";//REAL
P_Items [0]. BActive=TRUE;
P_Items [0]. HClient=1;//identity ID, different ITEM is not the same as
P_Items [0]. DwBlobSize=0;
P_Items [0]. PBlob=NULL;
P_Items [0]. VtRequestedDataType=5;//data type 5 to REAL



I write synchronization, even is AB - PLC, asynchronous can't write, the building Lord will write?? Consult


More than a read-only can be read, there is a problem, refer to my questions

CodePudding user response:

String to use a2w turn the line
LPWSTR ItemID=A2W (cstrings);
  • Related