Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/roald87/tcerror
Translate TwinCAT error codes
https://github.com/roald87/tcerror
beckhoff beckhoff-twincat beckhoff-twincat-plc industrial-automation twincat twincat-ads twincat3
Last synced: about 1 month ago
JSON representation
Translate TwinCAT error codes
- Host: GitHub
- URL: https://github.com/roald87/tcerror
- Owner: Roald87
- License: mit
- Created: 2022-06-30T06:13:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-16T10:04:33.000Z (5 months ago)
- Last Synced: 2024-10-12T21:42:12.719Z (2 months ago)
- Topics: beckhoff, beckhoff-twincat, beckhoff-twincat-plc, industrial-automation, twincat, twincat-ads, twincat3
- Language: HTML
- Homepage:
- Size: 2.74 MB
- Stars: 26
- Watchers: 5
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# TcError
Functions and datatypes which describe TwinCAT errors.
## Installation
[Download](https://github.com/Roald87/TcError/releases) from the releases page, or install via [📦 Twinpack](https://github.com/Zeugwerk/Twinpack).
## Example
Can be used to wrap existing TwinCAT Function Blocks to add clear error codes and messages.
![](example.png)
### Code
```
FUNCTION_BLOCK FB_CoeReaderEx EXTENDS FB_EcCoESdoReadEx
VAR_OUTPUT
eAdsError : TcError.AdsErrorCodes;
END_VAR
VAR
errorDescription : Tc2_System.T_MaxString;
END_VARSUPER^();
eAdsError := TcError.ToAdsErrorCode(SUPER^.nErrId);
errorDescription := TcError.AdsErrorCodeDescription(eAdsError);
```## Manual
### ADS errors
- `TYPE AdsErrorCodes` : Enum containing all ADS error codes.
- `FUNCTION ToAdsErrorCode`: Convert an ADS error code of type `UDINT` to the `AdsErrorCodes` datatype.
- `FUNCTION AdsErrorCodeDescription`: Returns an description of the error from the `AdsErrorCodes` datatype.#### Example
```
PROGRAM MAIN
VAR
adsErrorId : UDINT := 1802;
adsErrorCode : AdsErrorCodes;
errorDescription : T_MaxString;
END_VARadsErrorCode := TcError.ToAdsErrorCode(adsErrorId); // ADSERR_DEVICE_NOMEMORY;
errorDescription := TcError.AdsErrorCodeDescription(adsErrorCode); // 'Insufficient memory.'
```### Win32 errors
- `TYPE Win32ErrorCodes` : Enum containing all Win32 error codes.
- `FUNCTION ToWin32ErrorCode`: Convert an Win32 error code of type `UDINT` to the `Win32ErrorCodes` datatype.
- `FUNCTION Win32ErrorCodeDescription`: Returns an description of the error from the `Win32ErrorCodes` datatype.#### Example
```
PROGRAM MAIN
VAR
win32ErrorId : UDINT := 82;
win32ErrorCode : Win32ErrorCodes;
errorDescription : T_MaxString;
END_VARwin32ErrorCode := TcError.ToWin32ErrorCode(win32ErrorId); // ERROR_CANNOT_MAKE;
errorDescription := TcError.Win32ErrorCodeDescription(win32ErrorCode); // 'The directory or file cannot be created.'
```