How can I get the diagnostic message in plain text in the PLC?

I get the diagnostic number from the flatbuffer. However, the assignment to plain text is missing. Unfortunately, this cannot be copied from the documentation (https://docs.automation.boschrexroth.com/doc/2072012419/080f0001-error-during-backup-or-restoration-of-script-manager/latest/en/) and mapped because the subelements are created as links which makes it just to hard to copy.

Are the diagnostic messages available somewhere as a table or Excel sheet or can I also query the plain text via the flat buffer? I have tried it via the method in "diagnosis/get/text/detailed" but I always get the error message 'Function not implemented'.

Code:

_writeDLNode(Execute:=TRUE, Value:=_mainDiagnosisNumber[0], NodeName:='diagnosis/get/text/detailed');

Where the _mainDiagnosisNumber is set by the _pDiagnosisTable^.getMainDiagnosisNumber() Function.

Best reply by CodeShepherd

As there are flatbuffer (no standard data types) used in the PLC using the get text function via the Data Layer nodes looks like this:

Declaration:

 

PROGRAM PROG_common_log_diagnosis_fbs_GetMainDiagnosisText
VAR
	//Data for creating values to send in the request
	fbs_GetMainDiagnosisText: common_log_diagnosis_fbs_GetMainDiagnosisText;
	fbs_GetDetailedDiagnosisText: common_log_diagnosis_fbs_GetDetailedDiagnosisText;
	fbBuilder: flatbuffers.FlatBufferBuilder;
	udiStringMain: UDINT;
	udiStringDetail: UDINT;
	//Data Layer pathes
	NodePathMain: STRING(255) := 'diagnosis/get/text/main';
	NodePathDetail: STRING(255) := 'diagnosis/get/text/detailed';
	//Diagnosis numbers
	strMainDiag: STRING := '090A0000';
	strDetailDiag : STRING := '0C550145';	
	//Reading function
	fb_DL_ReadNodeValueType02: DL_ReadNodeValueType02;
	bExecute: BOOL;
	bDone: BOOL;
	bActive: BOOL;
	bError: BOOL;
	ErrorID: CXA_Datalayer.ERROR_CODE;
	ErrorIdent: CXA_Datalayer.ERROR_STRUCT;
	NodePath: STRING(255);
	DataReadOut: CXA_Datalayer.DL_NodeValue;
	fb_R_TRIG: R_TRIG;
	bMain: BOOL;
	bDetail: BOOL;
	fb_DL_ReadNode: DL_ReadNode;
	DataReadIn: CXA_Datalayer.DL_NodeValue;		
	pData: POINTER TO STRING;
	//Read text
	strDiagText: STRING;
END_VAR

 

Implementation:

 

IF 	bMain THEN
	bMain := FALSE;
	bExecute := TRUE;
	fbBuilder(forceDefaults := TRUE);
	udiStringMain := fbBuilder.createString(strMainDiag);
	fbs_GetMainDiagnosisText.startGetMainDiagnosisText(fbBuilder);
	fbs_GetMainDiagnosisText.addMainDiagnosisNumber(udiStringMain);
	fbBuilder.finish(fbs_GetMainDiagnosisText.endGetMainDiagnosisText());
	DataReadIn.SetFlatbuffer(fbBuilder);
	NodePath := NodePathMain;	
ELSIF bDetail THEN
	bDetail := FALSE;
	bExecute := TRUE;	
	fbBuilder(forceDefaults := TRUE);
	udiStringMain := fbBuilder.createString(strMainDiag);
	udiStringDetail := fbBuilder.createString(strDetailDiag);	
	fbs_GetDetailedDiagnosisText.startGetDetailedDiagnosisText(fbBuilder);	
	fbs_GetDetailedDiagnosisText.addRelatedMainDiagnosisNumber(udiStringMain);
	fbs_GetDetailedDiagnosisText.addDetailedDiagnosisNumber(udiStringDetail);
	fbBuilder.finish(fbs_GetDetailedDiagnosisText.endGetDetailedDiagnosisText());
	DataReadIn.SetFlatbuffer(fbBuilder);	
	NodePath := NodePathDetail;	
END_IF

fb_DL_ReadNodeValueType02(
	Execute:= bExecute, 
	Done=> bDone, 
	Active=> bActive, 
	Error=> bError, 
	ErrorID=> ErrorID, 
	ErrorIdent=> ErrorIdent, 
	ClientId:= , 
	NodeName:= NodePath, 
	NodeValueIn:= DataReadIn,
	NodeValueOut:= DataReadOut);
	
fb_R_TRIG(CLK:= bDone, Q=> );
IF fb_R_TRIG.Q THEN
	bExecute := FALSE;		
	DataReadOut.GetValueString(Value=>pData);
	strDiagText := pData^;	
END_IF

 

In the Data Layer viewer it works as you can see here:

For main diagnosis number send object '{"mainDiagnosisNumber": "090A0000"}':

Data Layer viewer get main diagnosis text

For detail diagnosis number send object '{"detailedDiagnosisNumber": "0C550145", "relatedMainDiagnosisNumber": "090A0000"}':

Data Layer viewer get detailed diagnosis text

View original
3 replies