Skip to content

How to print value of variables in softplc #6

Description

@mariusroe96

Hello,

i tried to print out the values of located vars and normal vars in the run() function of the plc.c file, but I cant figure out how. The vars do not change their values during execution of the softplc.

Something like in the "and_logic_debug_located_vars":

printf("IX0.0 = %s\n", *__IX0_0? "TRUE" : "FALSE");
printf("IX0.1 = %s\n", *__IX0_1? "TRUE" : "FALSE");
printf("QX0.0 = %s\n", *__QX0_0? "TRUE" : "FALSE");

printf("\n");

//LOCATED
printf("INICIAR: %s\n", (BOOL)__GET_LOCATED(STD_RESSOURCE__INST0.INICIAR,)? "TRUE" : "FALSE");

// printf("INICIAR: %s\n", (BOOL)*STD_RESSOURCE__INST0.INICIAR.value ? "TRUE" : "FALSE");
printf("PARAR: %s\n", (BOOL)__GET_LOCATED(STD_RESSOURCE__INST0.PARAR,)? "TRUE" : "FALSE");
printf("LAMP: %s\n", (BOOL)__GET_LOCATED(STD_RESSOURCE__INST0.LAMP,)? "TRUE" : "FALSE");

printf("INICIAR: %s\n", *(BOOL*)__GET_VAR(STD_RESSOURCE__INST0.INICIAR,)? "TRUE" : "FALSE");

// printf("INICIAR: %s\n", (BOOL)STD_RESSOURCE__INST0.INICIAR.value ? "TRUE" : "FALSE");
printf("PARAR: %s\n", (BOOL
)__GET_VAR(STD_RESSOURCE__INST0.PARAR,)? "TRUE" : "FALSE");
printf("LAMP: %s\n", (BOOL*)__GET_VAR(STD_RESSOURCE__INST0.LAMP,)? "TRUE" : "FALSE");

It seems like the printed valus are not correct.

Can anyone help with this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions