get_last_alarm (Manual Mode)
This section explains how to use 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 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
#include "DRFLEx.h"
#include <iostream>
#include <thread>
#include <chrono>
using namespace DRAFramework;
using namespace std;
int main() {
CDRFLEx drfl;
// Preconditions:
// - Connection established (open_connection)
// - Manual (Teach) mode active
cout << "[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) {
cout << "-------------------------------------------\n";
cout << "[LAST ALARM INFO]\n";
cout << "Code : " << pAlarm->_iErrorCode << endl;
cout << "Message : " << pAlarm->_szAlarmMsg << endl;
cout << "Level : " << pAlarm->_iLevel << " (0:Info, 1:Warn, 2:Error)\n";
cout << "Group : " << pAlarm->_iGroup << endl;
cout << "-------------------------------------------\n";
}
else {
cout << "[Alarm Check] No recent alarms detected.\n";
}
return 0;
}
Tips
Use this function immediately after stop or release_protective_stop to determine the reason for interruption.
Record alarm logs during teaching sessions for traceability and error analysis.
Combine with LED feedback (set_state_led_color) to visualize alarm severity.
Useful for creating custom alarm dashboards or automated recovery notifications in teach mode.