Forum Migration Notice
We're transitioning to a more modern community platform by the end of this year. Learn about the upcoming changes and what to expect.

Send error domain, number and title to PLC

Hi all,
I'm doing an application in which I have to detect errors and then send error domain, number and title to PLC trough Profinet. I'm not too expert in RAPID/RobotStudio, so I have 3 questions.
1) Is what I've written until now correct and the correct way for detecting errors? I wrote the following code in a semi-static parallel task:

   VAR intnum err_interrupt;
    VAR errdomain err_domain;
    VAR num err_number;
    VAR errtype err_type;
    VAR trapdata err_data;
    VAR string titlestr; 

PROC main()  
    
    IF first THEN          
        IDelete err_interrupt;
        CONNECT err_interrupt WITH trap_err;
        IError COMMON_ERR, TYPE_ALL, err_interrupt;
        first := FALSE;
    ENDIF
 ........
   " 2) the main is doing also other things like reading the robot position continuosly, would be better to have a task only for errors management?"
.........
ENDPROC

TRAP trap_err
     GetTrapData err_data;
     ReadErrData err_data, err_domain, err_number, err_type  \Title:=titlestr;
     SetGO GO_ErrDomain, err_domain;
     SetGO GO_ErrNumber, err_number;
ENDTRAP

3) At the moment I'm sending to PLC only the error domain and number, how can I send a string?

Thank you a lot in advance!