For information on the latest version, please have a look at 1.33.5.
set_on_tp_log (Manual Mode)
This section explains how to use set_on_tp_log during Manual (Teach) operations. This function registers a callback function that receives log messages from the Teach Pendant (TP). It is mainly used to display or store TP console messages, warnings, and information strings that occur while teaching or executing DRL programs in Manual mode.
Typical usage
Mirror TP logs in the host PC console for monitoring and debugging.
Record log messages to a file for teaching session documentation.
Detect specific log patterns (e.g., “Warning”, “Error”) to trigger responses or visual alerts.
Correlate log messages with progress or popup events for deeper diagnostics.
Note
Each callback receives one text line (up to 256 bytes) from the TP.
Use file logging or filtering logic for long teaching sessions.
Example: Log TP messages and highlight warnings
#include <cstdio>
#include <cstring>
#include <ctime>
#include <fstream>
#include <string>
#include <thread>
#include <chrono>
// Utility to get timestamp
string GetTimestamp()
{
time_t now = time(0);
tm* ltm = localtime(&now);
char buf[64];
sprintf(buf, "%04d-%02d-%02d %02d:%02d:%02d",
1900 + ltm->tm_year, 1 + ltm->tm_mon, ltm->tm_mday,
ltm->tm_hour, ltm->tm_min, ltm->tm_sec);
return string(buf);
}
// TP log callback
void OnTpLog(const char* strLog)
{
printf("[%s] %s\n", GetTimestamp().c_str(), strLog);
// Write log to file
ofstream logFile("tp_manual_log.txt", ios::app);
if (logFile.is_open())
{
logFile << "[" << GetTimestamp() << "] " << strLog << endl;
logFile.close();
}
// Highlight warnings and errors
if (strstr(strLog, "Warning") != nullptr)
printf(">>> WARNING detected in TP log\n");
else if (strstr(strLog, "Error") != nullptr)
printf(">>> ERROR detected in TP log\n");
}
drfl.open_connection("192.168.137.100");
drfl.set_on_tp_log(OnTpLog);
printf("[Teach] Waiting for TP log messages...\n");
while (true)
this_thread::sleep_for(chrono::seconds(1));
When registered, this callback function executes automatically whenever a log message is generated by the Teach Pendant (TP). It allows the user to mirror TP log outputs, detect anomalies, or store activity history for improved transparency and debugging during manual operations.
Tips
Use to capture TP logs for debugging or post-teaching analysis.
Combine with set_on_tp_popup for event-linked log tracking.
Highlight warnings or errors in the host log for quick operator awareness.