HRESULT
Most methods of the TwinCAT 3 Plastic Technology Functions return information about the success of the execution by means of a HRESULT value. This is formed from individual 16 bits of information and a 16-bit error code. This results in the 32-bit data type. The basic structure is as follows:
Bits | 31 | 30-16 | 15-0 |
|---|---|---|---|
Meaning | 0 = Success, 1 = Error | Characteristic identifier of the Plastic Technology Functions: 0x1B00 | Error code: Typically matching the enumeration E_AdsErr |
There are several ways to evaluate an HRESULT error code:
- Basically, the Tc3_Module library offers simple functions for checking.
- SUCCEEDED() --> Success
- FAILED() --> Failure
- As the
HRESULTdata type is signed, bit 31 can also be checked by a greater than/less than comparison. - >= 0 --> Success
- < 0 --> Failure
- The F_SucceededHr(...) function combines two error code evaluation processes.
- The function itself returns a boolean
TRUEif theHRESULTvalue indicates a success. - If the
HRESULTindicates a failure, the information is copied to theDestinationvariable passed.
See also PLC Programming Conventions - Error Codes
Further Information