This article shows how to detect an alarm of a Yaskawa Motoman controller from a PC, read its code and its text, and reset it, in C# or Python. It gives a complete program that checks the result of the reset.

## Prerequisites

- The SDK is connected to the controller: see [Connect to your robot](/yaskawa/documentation/connect).
- To reset, the controller accepts the remote commands. Reading the alarms works in any mode.

## Alarm or error

| State                           | Detect                                  | Clear                               |
| ------------------------------- | --------------------------------------- | ----------------------------------- |
| Alarm: the controller stops     | `GetStatusInformation().Alarming`       | `AlarmReset(AlarmResetType.Reset)`  |
| Error: a message on the pendant | `GetStatusInformation().ErrorOccurring` | `AlarmReset(AlarmResetType.Cancel)` |

`GetAlarm` reads the code, the sub code, the time and the text of each alarm. `GetAlarmExtended` adds the texts of the sub codes.

## Example

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

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

        RobotStatusData status = robot.HighSpeedEServer.GetStatusInformation();

        if (status.Alarming || status.ErrorOccurring)
        {
            // 1. Read the alarms, the latest first
            foreach (RobotRecentAlarm which in Enum.GetValues(typeof(RobotRecentAlarm)))
            {
                RobotAlarmData alarm = robot.HighSpeedEServer.GetAlarm(which);
                if (alarm.Code != 0)
                    Console.WriteLine($"{alarm.OccurringTime} {alarm.Code} {alarm.Text}");
            }

            // 2. Remove the cause on the cell, then reset
            robot.HighSpeedEServer.AlarmReset(status.Alarming ? AlarmResetType.Reset : AlarmResetType.Cancel);

            // 3. Check that the alarm is gone
            status = robot.HighSpeedEServer.GetStatusInformation();
            Console.WriteLine(status.Alarming ? "The alarm is still active" : "Alarm reset");
        }

        robot.Disconnect();
        /**/
    }
}
```

**Python : HowToReadResetAlarms**
```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
from underautomation.yaskawa.high_speed_e_server.robot_recent_alarm import RobotRecentAlarm

##
robot = YaskawaRobot()
robot.connect(ConnectParameters("192.168.0.1"))
hses = robot.high_speed_e_server

status = hses.get_status_information()

if status.alarming or status.error_occurring:
    # 1. Read the alarms, the latest first
    for which in RobotRecentAlarm:
        alarm = hses.get_alarm(which)
        if alarm.code != 0:
            print(f"{alarm.occurring_time} {alarm.code} {alarm.text}")

    # 2. Remove the cause on the cell, then reset
    hses.alarm_reset(AlarmResetType.Reset if status.alarming else AlarmResetType.Cancel)

    # 3. Check that the alarm is gone
    status = hses.get_status_information()
    print("The alarm is still active" if status.alarming else "Alarm reset")

robot.disconnect()
##
```

The program:

1. reads the status, and stops if there is no alarm and no error;
2. prints each alarm reported by the controller, the most recent first;
3. resets the alarm, or cancels the error;
4. reads the status again to check that the alarm is gone.

## Before the reset

A reset does not remove the cause of the alarm. If the cause is still present, the alarm comes back at once. Log the code and the text before the reset, and let an operator check the cell when the alarm concerns safety or a collision.

## Troubleshooting

- **The reset is refused:** the remote mode is off. See [Prepare the controller](/yaskawa/documentation/connect#prepare_the_controller).
- **The alarm comes back:** its cause is still present. Look for the code in the alarm manual of your controller.
- **`Code` is `0`:** there is no alarm at this position of the list.

## What to read next

- [Alarms](/yaskawa/documentation/hses-alarms): the reference of the alarm methods.
- [Monitor the state of the robot](/yaskawa/documentation/how-to-monitor-state).