APIs, concepts, guides, and more
Error Logging

Learn how to handle errors and read error logs from a RapidCodeObject.

Warning
This is a sample program to assist in the integration of the RMP motion controller with your application. It may not contain all of the logic and safety features that your application requires. We recommend that you wire an external hardware emergency stop (e-stop) button for safety when using our code sample apps. Doing so will help ensure the safety of you and those around you and will prevent potential injury or damage.

The sample apps assume that the system (network, axes, I/O) are configured prior to running the code featured in the sample app. See the Configuration page for more information.


In this page:


📜 Error Logs

Learn how to read RsiError objects from the Error Logging 📖 . This sample demonstrates how to turn off exceptions, perform operations that generate errors, and read error messages from the error log.

/* This sample demonstrates how to read RsiError objects from the error log.
It shows how to turn off exceptions, perform operations that generate errors,
and then read and display error messages from the error log.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 Error Logs");
// get rmp objects
try
{
Helpers.CheckErrors(controller);
Axis axis = controller.AxisGet(axisNumber: 0);
// turn exceptions off (errors will be logged as RsiError objects)
controller.ThrowExceptions(false);
axis.ThrowExceptions(false);
// cause an errors
controller.RecorderStart(); // recorder count is zero
axis.MoveVelocity(0.0, 0.0); // zero acceleration
// print error count
var controllerErrorCount = controller.ErrorLogCountGet();
var axisErrorCount = axis.ErrorLogCountGet();
Console.WriteLine($"Controller error count: {controllerErrorCount} (expected: 1)");
Console.WriteLine($"Axis error count: {axisErrorCount} (expected: 1)");
// print controller errors
while(controller.ErrorLogCountGet() > 0)
{
// ErrorLogGet retrieves and removes the next error from the log
RsiError error = controller.ErrorLogGet();
Console.WriteLine($" Controller Error: {error.Message}");
}
// print axis errors
while( axis.ErrorLogCountGet() > 0)
{
RsiError error = axis.ErrorLogGet();
Console.WriteLine($" Axis Error: {error.Message}");
}
// print error count after reading logs
Console.WriteLine($"Controller error count: {controller.ErrorLogCountGet()} (expected: 0)");
Console.WriteLine($"Axis error count: {axis.ErrorLogCountGet()} (expected: 0)");
// verify error count
if(controllerErrorCount < 1 || axisErrorCount < 1)
throw new Exception("❌ Error log did not record expected errors.");
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
static void CheckErrors(RapidCodeObject rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...
Definition _helpers.cs:15
Helpers class provides static methods for common tasks in RMP applications.
Definition _helpers.cs:5
void MoveVelocity(double velocity)
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5870
Axis * AxisGet(int32_t axisNumber)
AxisGet returns a pointer to an Axis object and initializes its internals.
void RecorderStart()
Start recording data.
static MotionController * Get()
Get an already running RMP EtherCAT controller.
void Delete(void)
Delete the MotionController and all its objects.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:800
void ThrowExceptions(bool state)
Configure a class to throw exceptions.
const RsiError *const ErrorLogGet()
Get the next RsiError in the log.
int32_t ErrorLogCountGet()
Get the number of software errors in the error log.
Represents the error details thrown as an exception by all RapidCode classes. This class contains an ...
Definition rsi.h:111