Logo
UNICENS V2.3.0-4567
User Manual and API Reference
Supervisor Diagnosis Mode

Introduction

When entering the Supervisor Diagnosis Mode the Network Supervisor is responsible to execute a certain network diagnosis which is configured in the initialization structure. As possible network diagnosis type the application can choose between the following ones:

  • Full Duplex Diagnosis (FDX)
  • Half Duplex Diagnosis (HDX)

As shown in the following example the application must specify the respective diagnosis type and callback functions during the initialization.

void App_Initialize(void)
{
Ucs_InitData_t init_data;
Ucs_SetDefaultConfig(&init_data);
/* Network Events */
init_data.network.status.cb_fptr = &App_OnNetworkStatus;
/* Network Supervisor */
init_data.supv.report_mode_fptr = &App_OnSupvReportMode;
/* Diagnosis Mode */
init_data.supv.diag_fdx_fptr = &App_OnFullDuplexDiagReport;
init_data.supv.diag_hdx_fptr = &App_OnHalfDuplexDiagReport;
/* ... further initialization ... */
Ucs_Init(&init_data, &App_OnInitResult);
}

Since the Supervisor Diagnosis Mode is not supported as initial Supervisor Mode the application may set the Supervisor Inactive Mode as initial Supervisor Mode. As soon as the Supervisor reports "Inactive.Ready" the application can call Ucs_Supv_SetMode() to set the Supervisor Diagnosis Mode.

After entering the Supervisor Diagnosis Mode the Supervisor is responsible to perform the following tasks:

  • Execute the pre-configured network diagnosis
  • Call the respective callback function to report the diagnosis results
  • Automatically return to Supervisor Inactive Mode after finishing the network diagnosis

The following example code shows how to print relevant information on different diagnosis reports.

static void App_OnFullDuplexDiagReport(Ucs_Fdx_Report_t *report_ptr, void *user_ptr)
{
switch (report_ptr->code)
{
printf("[FDX Diagnosis] segment=branch %02X, seg=0x%02X, source_id=%04X, target_id=%04X.\n",
report_ptr->segment.branch, report_ptr->segment.num, report_ptr->segment.source.diagnosis_id,
report_ptr->segment.target.diagnosis_id);
break;
printf("[FDX Diagnosis] CableLinkDiagnosis: branch=%02X, seg=0x%02X, source_id=%04X, \
cable_link_info 0x%02X.\n",
report_ptr->segment.branch, report_ptr->segment.num, report_ptr->segment.source.diagnosis_id,
report_ptr->cable_link_info);
break;
printf("[FDX Diagnosis] finished\n");
break;
printf("[FullDuplex Diagnosis] Unexpected error: 0x%02X.\n", report_ptr->err_info);
break;
printf("[FullDuplex Diagnosis] Diagnosis aborted.\n");
break;
default:
printf("[FullDuplex Diagnosis] Unexpected return code 0x%02X.\n", report_ptr->code);
break;
}
}
static void App_OnHalfDuplexDiagReport(Ucs_Hdx_Report_t *report_ptr, void *user_ptr)
{
switch (report_ptr->code)
{
printf("[HDX Diagnosis] Node position 0x%02X intact, node address 0x%02X.\n",
report_ptr->position, report_ptr->signature_ptr->node_address);
break;
printf("[HDX Diagnosis] Answer from wrong position 0x%02X, node address 0x%02X.\n",
report_ptr->position, report_ptr->signature_ptr->node_address);
break;
printf("[HDX Diagnosis] Ring break detected: unable to reach node 0x%02X.\n", report_ptr->position);
printf("[HDX Diagnosis] Cable diagnosis result=0x%02X\n", report_ptr->cable_diag_result);
break;
printf("[HDX Diagnosis] no ring break detected.\n");
break;
printf("[HDX Diagnosis] unexpected error.\n");
break;
printf("[HDX Diagnosis] expected result message did not arrive in time.\n");
break;
printf("[HDX Diagnosis] unexpected error. Cable diagnosis result=0x%02X.\n",
report_ptr->cable_diag_result);
break;
printf("[HDX Diagnosis] diagnosis ended.\n");
break;
default:
printf("[HDX Diagnosis] Unknown result=0x%02X.\n", report_ptr->code);
break;
}
}