Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

__TRY __CATCH questions

Joan M
2017-05-06
2017-05-09
  • Joan M - 2017-05-06

    Hello all,

    I've been using structured exception handling in C and in other high level languages and I'm familiar with it's intended use.

    In one big program I'm developing now with TwinCAT 3 I have a problem in which randomly my programming computer gets disconnected from the controller and the controller reverts to configuration mode or simply hangs.

    There are plenty of loops and pointers involved and, even I've seen that same program working before... now it fails some times... (I've changed the TwinCAT version).

    Given __TRY __CATCH... are there to be able to help the programmer when a loop or a pointer are not working as expected I've tried to put a __TRY clause at the beginning and a __CATCH clause at the end of the main cycle (and of course the __END_TRY at the end), but the same behavior happens.

    See page 5 and 6 of the following PSF file: https://www.codesys.com/fileadmin/data/Images/Download/FeaturesAndImprovementsV3.5SP6_en.pdf

    Should I activate something to get the SEH working in the controller (a PC)?

    And... How I should declare HandleException? Which type does it has?

    As always thank you very much.

    Joan.

     
  • josepmariarams - 2017-05-08

    Hi Joan.

    It works for me as:

    You can found __system.exceptionCode enum on Codesys help.

    IMG: Captura de 2017

    IMG: Captura de 2017

    IMG: Captura de 2017

     
  • Joan M - 2017-05-09

    Thank you Josep M.

    It was well implemented (as you did and also as the code in the sample on that linked PDF file).

    I have not been able to find information about the enumeration __system.exceptionCode, but by now I think I won't need it.

    Thank you again!

     

Log in to post a comment.