This page shows how to read the alarms of a Yaskawa Motoman controller with the SDK, and how to reset them from a PC. It covers every controller with the High Speed Ethernet Server.

## Read the alarms

The controller reports up to 4 alarms. `GetAlarm(which)` reads one of them, with its code, its text and the time it occurred.

**C# : AlarmRead**
```csharp
using UnderAutomation.Yaskawa;
using UnderAutomation.Yaskawa.HighSpeedEServer;

public class AlarmRead
{
    static void Main()
    {
        var robot = new YaskawaRobot();
        robot.Connect("192.168.0.1");

        /**/
        // The controller reports up to 4 alarms, the most recent first
        foreach (RobotRecentAlarm which in Enum.GetValues(typeof(RobotRecentAlarm)))
        {
            RobotAlarmData alarm = robot.HighSpeedEServer.GetAlarm(which);

            // Code 0 means that there is no alarm at this position
            if (alarm.Code == 0) continue;

            Console.WriteLine($"{which}: {alarm.Code} {alarm.Text} at {alarm.OccurringTime} (data {alarm.Data}, type {alarm.Type})");
        }
        /**/

        robot.Disconnect();
    }
}
```

**Python : AlarmRead**
```python
from underautomation.yaskawa.yaskawa_robot import YaskawaRobot
from underautomation.yaskawa.connect_parameters import ConnectParameters
from underautomation.yaskawa.high_speed_e_server.robot_recent_alarm import RobotRecentAlarm

robot = YaskawaRobot()
robot.connect(ConnectParameters("192.168.0.1"))

##
# The controller reports up to 4 alarms, the most recent first
for which in RobotRecentAlarm:
    alarm = robot.high_speed_e_server.get_alarm(which)

    # Code 0 means that there is no alarm at this position
    if alarm.code == 0:
        continue

    print(f"{which.name}: {alarm.code} {alarm.text} at {alarm.occurring_time} (data {alarm.data}, type {alarm.type})")
##

robot.disconnect()
```

**Matlab : AlarmRead**
```matlab
NET.addAssembly(fullfile(pwd, 'net48', 'UnderAutomation.Yaskawa.dll'));
import UnderAutomation.Yaskawa.*
import UnderAutomation.Yaskawa.HighSpeedEServer.*

robot = YaskawaRobot();
robot.Connect('192.168.0.1');

%%
% Up to 4 alarms, the most recent first
alarms = [RobotRecentAlarm.Latest, RobotRecentAlarm.SecondLatest, ...
          RobotRecentAlarm.ThirdLatest, RobotRecentAlarm.FourthLatest];

for k = 1:numel(alarms)
    alarm = robot.HighSpeedEServer.GetAlarm(alarms(k));
    if alarm.Code ~= 0
        fprintf('%d %s at %s
', alarm.Code, char(alarm.Text), char(alarm.OccurringTime));
    end
end
%%

robot.Disconnect();
```

| Property        | Content                                                           |
| --------------- | ----------------------------------------------------------------- |
| `Code`          | Alarm number, as shown on the pendant. `0` when there is no alarm |
| `Data`          | Sub code of the alarm                                             |
| `Type`          | Type of the sub code                                              |
| `OccurringTime` | Date and time of the alarm, as a text of the controller           |
| `Text`          | Name of the alarm                                                 |

`RobotRecentAlarm.Latest` is the most recent alarm, `FourthLatest` the oldest of the four. `GetStatusInformation().Alarming` tells if an alarm is active, in one short request: test it first, then read the alarms.

The meaning of each code and the action to take are in the alarm manual of your controller.

## Read the sub codes

`GetAlarmExtended(which)` returns the same values, plus the texts of the sub codes. Use it to log the full context of an alarm.

**C# : AlarmReadExtended**
```csharp
using UnderAutomation.Yaskawa;
using UnderAutomation.Yaskawa.HighSpeedEServer;

public class AlarmReadExtended
{
    static void Main()
    {
        var robot = new YaskawaRobot();
        robot.Connect("192.168.0.1");

        /**/
        // Same as GetAlarm, plus the sub code texts of the alarm
        RobotAlarmDataExtended alarm = robot.HighSpeedEServer.GetAlarmExtended(RobotRecentAlarm.Latest);

        Console.WriteLine($"{alarm.Code} {alarm.Text} at {alarm.OccurringTime}");
        Console.WriteLine($"Information: {alarm.AdditionnalInformation}");
        Console.WriteLine($"Sub data: {alarm.SubData}");
        /**/

        robot.Disconnect();
    }
}
```

**Python : AlarmReadExtended**
```python
from underautomation.yaskawa.yaskawa_robot import YaskawaRobot
from underautomation.yaskawa.connect_parameters import ConnectParameters
from underautomation.yaskawa.high_speed_e_server.robot_recent_alarm import RobotRecentAlarm

robot = YaskawaRobot()
robot.connect(ConnectParameters("192.168.0.1"))

##
# Same as get_alarm, plus the sub code texts of the alarm
alarm = robot.high_speed_e_server.get_alarm_extended(RobotRecentAlarm.Latest)

print(f"{alarm.code} {alarm.text} at {alarm.occurring_time}")
print(f"Information: {alarm.additionnal_information}")
print(f"Sub data: {alarm.sub_data}")
##

robot.disconnect()
```

## Reset an alarm

`AlarmReset(type)` resets the alarms or cancels an error. It needs the remote mode. Remove the cause first: an alarm whose cause is still present comes back.

**C# : AlarmReset**
```csharp
using UnderAutomation.Yaskawa;
using UnderAutomation.Yaskawa.HighSpeedEServer;

public class AlarmReset
{
    static void Main()
    {
        var robot = new YaskawaRobot();
        robot.Connect("192.168.0.1");

        /**/
        RobotStatusData status = robot.HighSpeedEServer.GetStatusInformation();

        // Reset the alarms, once their cause is removed
        if (status.Alarming)
            robot.HighSpeedEServer.AlarmReset(AlarmResetType.Reset);

        // Cancel an error (a message that does not stop the controller)
        if (status.ErrorOccurring)
            robot.HighSpeedEServer.AlarmReset(AlarmResetType.Cancel);
        /**/

        robot.Disconnect();
    }
}
```

**Python : AlarmReset**
```python
from underautomation.yaskawa.yaskawa_robot import YaskawaRobot
from underautomation.yaskawa.connect_parameters import ConnectParameters
from underautomation.yaskawa.high_speed_e_server.alarm_reset_type import AlarmResetType

robot = YaskawaRobot()
robot.connect(ConnectParameters("192.168.0.1"))

##
status = robot.high_speed_e_server.get_status_information()

# Reset the alarms, once their cause is removed
if status.alarming:
    robot.high_speed_e_server.alarm_reset(AlarmResetType.Reset)

# Cancel an error (a message that does not stop the controller)
if status.error_occurring:
    robot.high_speed_e_server.alarm_reset(AlarmResetType.Cancel)
##

robot.disconnect()
```

| `AlarmResetType` | Use                                                               |
| ---------------- | ----------------------------------------------------------------- |
| `Reset`          | Reset the alarms (`GetStatusInformation().Alarming`)              |
| `Cancel`         | Cancel an error message (`GetStatusInformation().ErrorOccurring`) |

A complete program, with the check after the reset, is in [Read and reset alarms](/yaskawa/documentation/how-to-read-reset-alarms).

## Try it in the demo application

Everything on this page can be tried without writing code, in the **Alarms and system info** page of the [demo application](/yaskawa/documentation/demo-app).

![Alarms and system info page of the Yaskawa SDK demo application](/yaskawa/WinformsScreenshots/Alarm.jpg)

Its C# source is [AlarmControl.cs](https://github.com/underautomation/Yaskawa.NET/blob/main/UnderAutomation.Yaskawa.Showcase.Forms/Components/AlarmControl.cs).

## Reference

**Methods of HighSpeedEServerClientBase**
```csharp
// Resets alarms or cancels errors on the robot controller. Use Reset to clear alarm conditions after resolving the cause. Use Cancel for recoverable errors that don't require alarm reset.
RobotDataHeader AlarmReset(AlarmResetType type);

// Reads alarm information from the robot controller. Retrieves alarm code, type, occurrence time, and descriptive text.
RobotAlarmData GetAlarm(RobotRecentAlarm alarm);

// Retrieves extended alarm information including sub-code character strings. Provides more detailed information than GetAlarm for troubleshooting.
RobotAlarmDataExtended GetAlarmExtended(RobotRecentAlarm alarm);
```

Every method also exists in an asynchronous version, with the same name followed by `Async` and an optional `CancellationToken`.

**Members of HighSpeedEServer.RobotAlarmData**
```csharp
public class RobotAlarmData : RobotData {
    // Gets the alarm code identifying the specific alarm type.
    // Alarm codes are documented in the robot's maintenance manual.
    public int Code { get; }

    // Gets additional alarm data providing context about the alarm.
    // The meaning depends on the specific alarm code.
    public int Data { get; }

    // Gets the timestamp when the alarm occurred.
    // Format: "YYYY/MM/DD HH:MM:SS" (16 characters).
    public string OccurringTime { get; }

    // Gets the alarm message text describing the alarm condition.
    // Maximum 32 characters.
    public string Text { get; }

    // Gets the alarm type/category classification.
    public int Type { get; }
}
```

**Members of HighSpeedEServer.RobotAlarmDataExtended**
```csharp
public class RobotAlarmDataExtended : RobotAlarmData {
    // Gets additional information about the alarm condition.
    // Maximum 16 characters.
    public string AdditionnalInformation { get; }

    // Gets the sub-code data providing detailed error context.
    // Maximum 96 characters.
    public string SubData { get; }

    // Gets the reversed sub-code data.
    // Maximum 96 characters.
    public string SubDataReverse { get; }
}
```

**Members of HighSpeedEServer.RobotRecentAlarm**
```csharp
public enum RobotRecentAlarm {
    // The fourth most recent alarm.
    FourthLatest = 4

    // The most recent (current) alarm.
    Latest = 1

    // The second most recent alarm.
    SecondLatest = 2

    // The third most recent alarm.
    ThirdLatest = 3
}
```

**Members of HighSpeedEServer.AlarmResetType**
```csharp
public enum AlarmResetType {
    // Cancel the current error. Used for recoverable errors.
    Cancel = 2

    // Reset the current alarm. Requires the alarm condition to be resolved.
    Reset = 1
}
```