# Automatischer Neustart im Fehlerfall

{% hint style="warning" %}
Bitte beachten Sie, dass Sie für die volle Funktionalität der Funktion *OnException* **mindestens die Firmware Version 3.2** benötigen.

Die Funktion *OnException* ist für powerIO Geräte vorkonfiguriert und wird nur für powerIO Geräte empfohlen.
{% endhint %}

## Wie kann im Fehlerfall die Steuerung automatisch neugestartet werden?

Der nachfolgende Artikel beschreibt die Funktion, wie ein Ausnahmefehler (Exception) während der Laufzeit mitgeloggt werden kann und im Ausnahmezustand die Runtime oder das Gerät neugestartet werden kann.

## Beschreibung

* Das die Steuerung bei einer Exception **ohne** **“Nothalt”** (kein Kernel Panic) des Systems, die Meldung geloggt wird und ein Neustart der CODESYS Runtime erfolgt. Dies ist der “automatische Soft-reset im Fehlerfall”.
* Das die Steuerung bei einer Exception **mit “Nothalt”** (Kernel Panic) des Systems, die Meldung *versucht* zu loggen und ein Neustart des Systems erfolgt.

  Dies ist der “automatische Hard-reset im Fehlerfall”

## Funktionsbeschreibung *OnExceptionWrapper*

Im [Startprojekt "Leer" ](/hub/downloads/codesys-hvac-templates/template-start.md)befinden sich unter der Ansicht *POU* die zwei Funktionen

* *OnException* und
* *OnExceptionWrapper*

Die Funktion *OnExceptionWrapper*, ruft die *OnException* Funktion mit den angegebenen Einstellungen auf.

```iecst
OnException( 
	EventPrm:=EventPrm,
	xDebug := FALSE,
	xLogExceptionToFile:=TRUE,
	xRestartRuntimeOnException := TRUE,
	tExceptionFunctionTimeout := TIME#45S0MS
	);
```

## Aktivieren/deaktivieren der Exception Handling Funktion

1\. Klick auf "Taskkonfiguration "

![](https://ajeuwbhvhr.cloudimg.io/colony-recorder.s3.amazonaws.com/files/2023-11-21/a17783ad-3118-4508-870f-28e2ff3d4f84/user_cropped_screenshot.jpeg?tl_px=0,231\&br_px=859,712\&force_format=png\&width=860\&wat_scale=76\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/77328A_standard.png\&wat_pad=122,212)

2\. Klick auf "Systemereignisse"

![](https://ajeuwbhvhr.cloudimg.io/colony-recorder.s3.amazonaws.com/files/2023-11-21/17d6f9e5-ba67-49c0-a42f-e26e029ddea3/user_cropped_screenshot.jpeg?tl_px=274,0\&br_px=1134,480\&force_format=png\&width=860\&wat_scale=76\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/77328A_standard.png\&wat_pad=402,107)

3\. Prüfen ob "Exception" Funktion bereits vorhanden ist.

![](https://ajeuwbhvhr.cloudimg.io/colony-recorder.s3.amazonaws.com/files/2023-11-21/959b345f-8448-402d-9740-889e366bafed/user_cropped_screenshot.jpeg?tl_px=195,0\&br_px=1055,480\&force_format=png\&width=860\&wat_scale=76\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/77328A_standard.png\&wat_pad=402,173)

4\. Falls vorhanden, prüfen ob "Aktiv" ist

![](https://ajeuwbhvhr.cloudimg.io/colony-recorder.s3.amazonaws.com/files/2023-11-21/97f6a3fb-6992-46d4-b3f4-0048d7d99f92/screenshot.jpeg?tl_px=1905,0\&br_px=2765,480\&force_format=png\&width=860\&wat_scale=76\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/77328A_standard.png\&wat_pad=402,177)

5\. Falls nicht aktiv, dann aktivieren

![](https://ajeuwbhvhr.cloudimg.io/colony-recorder.s3.amazonaws.com/files/2023-11-21/6ed9e473-a7e9-40ab-a11b-3d5a7fb4ad65/screenshot.jpeg?tl_px=1905,0\&br_px=2765,480\&force_format=png\&width=860\&wat_scale=76\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/77328A_standard.png\&wat_pad=402,177)

## Hinzufügen der Exception Handling Funktion

Möchten Sie das Exception Handling für ein bestehendes Projekt hinzufügen, so können Sie die beiden Funktion aus dem [Startprojekt "Leer" ](/hub/downloads/codesys-hvac-templates/template-start.md)kopieren und den Event-Task selbst einpflegen.

Hierzu gehen Sie wie nachfolgend beschrieben vor:

1\. Navigieren zu "Taskkonfiguration "

![](https://ajeuwbhvhr.cloudimg.io/colony-recorder.s3.amazonaws.com/files/2023-11-21/b299d8ef-01ff-4bdf-a9e5-60610b76ab6e/user_cropped_screenshot.jpeg?tl_px=0,237\&br_px=859,718\&force_format=png\&width=860\&wat_scale=76\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/77328A_standard.png\&wat_pad=166,212)

2\. Tab "Systemereignisse" öffnen

![](https://ajeuwbhvhr.cloudimg.io/colony-recorder.s3.amazonaws.com/files/2023-11-21/fabaa8e3-458d-4506-be77-36339e0ddeec/user_cropped_screenshot.jpeg?tl_px=285,0\&br_px=1145,480\&force_format=png\&width=860\&wat_scale=76\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/77328A_standard.png\&wat_pad=402,105)

3\. "Event-Handler-hinzufügen" klicken

![](https://ajeuwbhvhr.cloudimg.io/colony-recorder.s3.amazonaws.com/files/2023-11-21/b8682791-790f-4cad-b089-b1c1d0b2499a/user_cropped_screenshot.jpeg?tl_px=46,0\&br_px=905,480\&force_format=png\&width=860\&wat_scale=76\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/77328A_standard.png\&wat_pad=402,131)

4\. Ereignis typ "Exception" auswählen

![](https://ajeuwbhvhr.cloudimg.io/colony-recorder.s3.amazonaws.com/files/2023-11-21/430c91c1-d6d7-4602-83a4-690c952034cb/user_cropped_screenshot.jpeg?tl_px=693,315\&br_px=1553,796\&force_format=png\&width=860\&wat_scale=76\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/77328A_standard.png\&wat_pad=402,212)

5\. Exception Name "OnExceptionWrapper" eingeben

![](https://ajeuwbhvhr.cloudimg.io/colony-recorder.s3.amazonaws.com/files/2023-11-21/d08770c6-8fe3-4339-88e2-ded86e4caad0/user_cropped_screenshot.jpeg?tl_px=494,279\&br_px=1258,706\&force_format=png\&width=764)

6\. Click "POUs"

![](https://ajeuwbhvhr.cloudimg.io/colony-recorder.s3.amazonaws.com/files/2023-11-21/586e7dc6-2d8e-4b1d-8352-cbb134b6478f/user_cropped_screenshot.jpeg?tl_px=803,293\&br_px=1568,720\&force_format=png\&width=764\&wat_scale=68\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/77328A_standard.png\&wat_pad=357,188)

7\. Click "OK"

![](https://ajeuwbhvhr.cloudimg.io/colony-recorder.s3.amazonaws.com/files/2023-11-21/b407b030-9d13-48a1-9c06-bf8ba6c15cb6/user_cropped_screenshot.jpeg?tl_px=542,395\&br_px=1402,876\&force_format=png\&width=860\&wat_scale=76\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/77328A_standard.png\&wat_pad=402,212)

8\. Wechseln der Ansicht zu "POUs"

![](https://ajeuwbhvhr.cloudimg.io/colony-recorder.s3.amazonaws.com/files/2023-11-21/a0288e24-8490-45c5-a66b-b3926deb77a8/user_cropped_screenshot.jpeg?tl_px=0,1211\&br_px=859,1692\&force_format=png\&width=860\&wat_scale=76\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/77328A_standard.png\&wat_pad=73,377)

9\. Funktion "OnExceptionWrapper (FUN) " öffnen

![](https://ajeuwbhvhr.cloudimg.io/colony-recorder.s3.amazonaws.com/files/2023-11-21/90abd384-bc64-430d-8ada-452f8c7e72d6/user_cropped_screenshot.jpeg?tl_px=0,20\&br_px=859,501\&force_format=png\&width=860\&wat_scale=76\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/77328A_standard.png\&wat_pad=143,212)

10\. "OnException" Funktion konfigurieren

![](https://ajeuwbhvhr.cloudimg.io/colony-recorder.s3.amazonaws.com/files/2023-11-21/a1ce65ed-e2d1-42b2-8a01-601add236224/user_cropped_screenshot.jpeg?tl_px=325,427\&br_px=1185,908\&force_format=png\&width=860\&wat_scale=76\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/77328A_standard.png\&wat_pad=402,212)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.powerio.com/hub/faq-and-news/hvac-codesys-faq/automatischer-neustart-im-fehlerfall.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
