cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

How can I read pending diagnostic in PLC

How can I read pending diagnostic in PLC

MrLurtle
Established Member

I already checked the examples described in the forum. 

https://developer.community.boschrexroth.com/t5/ctrlX-PLC/CXA-DataLayer-How-to-write-a-flatbuffer/m-...

But all examples described here, have methods, which returns a "pointer to real" or "pointer to string", ... so an easy datatype.

 

My task is, to read the pending diagnostic and in this case, the method returns an object "pointer to DiagnosticInformation from the table"

And I don´t know, how to get access to this returned table. I have no chance to the information to the returned diagnostic string.

Here´s my example:

Declaration:

 

PROGRAM PLC_PRG2
VAR
 	strMyInstancename : STRING := 'MyInstance';
	bRead: BOOL;
	bExecute: BOOL;
	strNodePath: STRING(255) := 'diagnosis/get/actual/log';
	fbDL_ReadNodeValue: DL_ReadNodeValue;
	DataRead: CXA_Datalayer.DL_NodeValue;	
	fbDiagInfo : CXA_AutomationCore_fbs.common_log_diagnosis_fbs_DiagnosisIdentificationWithTimestamp;
	
	pendingDiag: CXA_AutomationCore_fbs.common_log_diagnosis_fbs_DiagnosisIdentification;
	strTimeStamp: STRING;
	pendingDiag2: POINTER TO CXA_AutomationCore_fbs.common_log_diagnosis_fbs_DiagnosisIdentification;
END_VAR

 

Implementation:

 

IF bRead THEN
	bRead := FALSE;
	bExecute := TRUE;
END_IF	
IF fbDL_ReadNodeValue.Done THEN	
	fbDiagInfo.getRootAsDiagnosisIdentificationWithTimestamp(data:= DataRead.GetData(), size:= DataRead.GetSize());
	
	pendingDiag2 := fbDiagInfo.getDiagnosisIdentification();
	pendingDiag := pendingDiag2^;
	
	strTimeStamp := fbDiagInfo.getTimestamp();
	bExecute := FALSE;
END_IF

fbDL_ReadNodeValue(
	Execute:= bExecute, ClientId:= , NodeName:= strNodePath, NodeValue:= DataRead);

 

 

I get access to the Pointer, but I don´t know, how to get access to special content of this table:

HellCoder_0-1662725802326.png

What can i do to see the actual diagnostic?

HellCoder_1-1662725915885.png

 

5 REPLIES 5

MrLurtle
Established Member

I´ve got in on my own.

You have to extend the code with: 

	myDiagnosisNumber := pendingDiag.getMainDiagnosisNumber();
	myDetailDiagnosis := pendingDiag.getDetailedDiagnosisNumber();
	
	myDiagTimestamp           := fbDiagInfo.getTimestamp();

You have to use the pointer you return from method fbDiagInfo.getDiagnosisIndentification() to call additional methods.

For example "pendingDiag.getMainDiagnosisNumber()" to get the diagnosis number.  

See also here an example, how to read out the list of all pending diagnostics using CXA_Autiomationcore_fbs at least version 1.14.0.1 and CXA_Datalayer:

Declaration:

 

PROGRAM common_log_diagnosis_fbs_DiagnosisIdentificationWithTimestamp
VAR
	
	//fbs_DiagnosisIdentification: common_log_diagnosis_fbs_DiagnosisIdentification;
	fbs_ErrorList: common_log_diagnosis_fbs_ListDiagnosisIdentificationWithTimestamp;
	fbs_ErrorWithTimestamp: CXA_AutomationCore_fbs.common_log_diagnosis_fbs_DiagnosisIdentificationWithTimestamp;
	fbs_DL_ReadNodeValue: DL_ReadNodeValue;
	pDiagnosisTable: POINTER TO CXA_AutomationCore_fbs.common_log_diagnosis_fbs_DiagnosisIdentification;
	
	bExecute: BOOL;
	bDone: BOOL;
	bActive: BOOL;
	bError: BOOL;
	ErrorID: CXA_Datalayer.ERROR_CODE;
	ErrorIdent: CXA_Datalayer.ERROR_STRUCT;
	NodePath: STRING(255) := 'diagnosis/get/actual/list';
	DataRead: CXA_Datalayer.DL_NodeValue;
	fb_R_TRIG: R_TRIG;
	udiErrorListLength: UDINT;
	i: INT;
	arstrTimestamps: ARRAY[0..100] OF STRING;
	arstrMainDiagnosisNumber: ARRAY[0..100] OF STRING;
	arstrDetailedDiagnosisNumber: ARRAY[0..100] OF STRING;
	arstrEntity: ARRAY[0..100] OF STRING;

END_VAR

 

Implementation:

 

fbs_DL_ReadNodeValue(
	Execute:= bExecute, 
	Done=> bDone, 
	Active=> bActive, 
	Error=> bError, 
	ErrorID=> ErrorID, 
	ErrorIdent=> ErrorIdent, 
	ClientId:= , 
	NodeName:= NodePath, 
	NodeValue:= DataRead);

	
fb_R_TRIG(CLK:= bDone, Q=> );
IF fb_R_TRIG.Q THEN
	bExecute := FALSE;
	fbs_ErrorList.getRootAsListDiagnosisIdentificationWithTimestamp(data:= DataRead.GetData(), size:= DataRead.GetSize());
	udiErrorListLength := fbs_ErrorList.getListDiagnosisIdentificationWithTimestampLength();
	FOR i := 0 TO TO_INT(udiErrorListLength)-1 BY 1 DO
		fbs_ErrorList.getListDiagnosisIdentificationWithTimestamp(i,ADR(fbs_ErrorWithTimestamp));
		arstrTimestamps[i] := fbs_ErrorWithTimestamp.getTimestamp();
		pDiagnosisTable := fbs_ErrorWithTimestamp.getDiagnosisIdentification();		
		arstrMainDiagnosisNumber[i] := pDiagnosisTable^.getMainDiagnosisNumber();
		arstrDetailedDiagnosisNumber[i] := pDiagnosisTable^.getDetailedDiagnosisNumber();
		arstrEntity[i] := pDiagnosisTable^.getEntity();
	END_FOR		
END_IF

 

rku
Established Member

In CodeShepherds code

fbs_ErrorList.getListDiagnosisIdentificationWithTimestamp(i,ADR(fbs_ErrorWithTimestamp));

 should be

fbs_ErrorWithTimestamp := fbs_ErrorList.getListDiagnosisIdentificationWithTimestamp(i)^;

 ?

CodeShepherd
Community Moderator
Community Moderator

No, the line in my code is correct. Please see the library version I mentioned above. The "old" interface you are referring to, will not work.

See topic "Recommended method to identify new diagnostic error/warning?" for new information using library CXAC_Diagnostics.

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist