.. _manual_get_last_alarm: get_last_alarm (Manual Mode) ------------------------------------------ This section explains how to use :ref:`get_last_alarm ` during **Manual (Teach)** operations. This function retrieves the **most recent alarm or warning message** generated by the robot controller. It is typically used after an emergency stop, protective stop, or fault condition occurs to diagnose the cause and determine appropriate recovery steps. **Typical usage** - Display or log the **latest alarm information** after a stop or fault during teaching. - Identify whether the stop was caused by a **safety event**, **communication issue**, or **operator action**. - Automatically categorize alarms and suggest recovery actions in custom HMI applications. - Use in conjunction with :ref:`set_safe_stop_reset_type ` to design recovery logic. .. Note:: - The data is read-only and updated automatically whenever a new alarm occurs. - Use after motion or safety stop events to check for diagnostic messages. **Example: Read and display last alarm information after a safety stop** .. code-block:: cpp // Preconditions: // - Connection established (open_connection) // - Manual (Teach) mode active printf("[Alarm Check] Waiting for potential stop or error...\n"); this_thread::sleep_for(chrono::seconds(2)); LPLOG_ALARM pAlarm = drfl.get_last_alarm(); if (pAlarm) { printf("-------------------------------------------\n"); printf("[LAST ALARM INFO]\n"); printf("Code : %d\n", pAlarm->_iErrorCode); printf("Message : %s\n", pAlarm->_szAlarmMsg); printf("Level : %d (0:Info, 1:Warn, 2:Error)\n", pAlarm->_iLevel); printf("Group : %d\n", pAlarm->_iGroup); printf("-------------------------------------------\n"); } else { printf("[Alarm Check] No recent alarms detected.\n"); } **Tips** - Use this function immediately after :ref:`stop ` or :ref:`release_protective_stop ` to determine the reason for interruption. - Record alarm logs during teaching sessions for **traceability** and **error analysis**. - Combine with LED feedback (:ref:`set_state_led_color `) to visualize alarm severity. - Useful for creating custom **alarm dashboards** or automated recovery notifications in teach mode.