Monitor execution entities in PolyORB-HI-C
PolyORB-HI-C provides functions to monitor the current status of the following entities :
- Ports
- Devices
- Buses
The functions returns the value __PO_HI_SUCCESS when no error is encountered. Otherwose, another value is returned. Please see include/po_hi_monitor.h for the list of all potential returned values. When querying system status, the identifiers used to name execution entities are the one defined in the generated deployment.h file from Ocarina, in particular:
- __po_hi_port_t: identifier of a port
- __po_hi_bus_id: identifier of a bus
- __po_hi_device_id: identifier of a device
Getting the status
The status of an entity is reported in a structure having the type __po_hi_monitor_status_t. the structure is the following:
typedef struct
{
__po_hi_monitor_status_code_t status;
int n_failures;
__po_hi_monitor_failure_t* failures;
} __po_hi_monitor_status_t;
- status indicates the status of the entity and can have the following values:
- po_hi_monitor_status_ok
- po_hi_monitor_status_ko
- po_hi_monitor_status_unavailable
- n_failures is the number of failures reported
- failures is an array containing all the failure codes reported. Value of a failure code can be :
- po_hi_monitor_failure_unknown
- po_hi_monitor_failure_value
Available functions
The following functions are available:
- __po_hi_monitor_get_status_port (const __po_hi_port_t port, __po_hi_monitor_status_t*) - Get the status of a port.
- __po_hi_monitor_get_status_device (const __po_hi_device_id, __po_hi_monitor_status_t* ) - Get the status of a device
- __po_hi_monitor_get_status_bus (const __po_hi_bus_id, __po_hi_monitor_status_t* ) - Get the status of a bus
- __po_hi_monitor_report_failure_port (const __po_hi_port_t, const __po_hi_monitor_failure_t) - Get the status report for a port
- __po_hi_monitor_report_failure_device (const __po_hi_device_id, const __po_hi_monitor_failure_t) - Get the status report for a device
- __po_hi_monitor_report_failure_bus (const __po_hi_bus_id, const __po_hi_monitor_failure_t) - Get the status report for a bus
- __po_hi_monitor_recover_bus (const __po_hi_bus_id) - Signal the bus as functional
- __po_hi_monitor_recover_device (const __po_hi_device_id) - Signal the device as functional
- __po_hi_monitor_recover_port (const __po_hi_port_t) - Signal the port as functional
Example of use
The following block of code retrieve the status of a device and checks fi the device is still operating.
#include <deployment.h>
__po_hi_monitor_status_t device_status;
if (__po_hi_monitor_get_status_device (my_device, &device_status) != __PO_HI_SUCCESS)
{
printf ("Cannot get device status !\n");
}
if (device_status.status != po_hi_monitor_status_ok)
{
printf ("Error, device not ok !\n");
}
Changing states of entities
This API is available both for user-defined code and within the runtime. Status of entities may be also modified directly within the runtime. For example, when a device cannot send a data, it is declared as faulty and the monitor service would report it as not functional. In addition, when detecting that, the user code can also try to repair the device and declare it as functional again.