pranathi
pranathi

Reputation: 393

Copying 8 bytes of data from union to pointer in Structured text

I am new to structured text and barely getting started . I need to copy 8 bytes of data I receive over a CAN to another variable in structure in Structured text . Here is my code

TYPE msg :
    UNION
        data : msg_S;
        bytes : IO.CANMESSAGE;
    END_UNION
END_TYPE

TYPE msg_S :
    STRUCT
        temp1:INT;
        temp2:INT;
        temp3:INT;
        state :USINT;
        state1 :USINT;
        info : INT;
        faultcodes : POINTER TO INT;
        position : INT; 
        coolant :USINT;
        END_STRUCT
        END_TYPE

msg_data_bytes AT %Q*   : msg;

I am trying to copy data bytes I have in msg_S to faultcodes. I am trying to use memcpy as below

  memcpy(faultcodes,msg_data_bytes.bytes, 8); 

This is returning an error . How do I copy the data from msg_data_bytes.bytes to faultcodes ?

Upvotes: 0

Views: 48

Answers (0)

Related Questions