Plc programming – Lenze ETC Motion Control User Manual

Page 412

Advertising
background image

PLC programming

Library
CAN functions (only ETCxM)

8

8.8
8.8.6

l

412

EDSTCXN EN 2.0

8.8.6.5

ClearCanMsg (only ETCxM)

FUNCTION ClearCanMsg: BOOL

VAR_INPUT

handle_pr

: DINT;

(* Handle on the management structure *)

END_VAR

FUNCTION

This function can be used to delete the reception FIFO (see function
DefineCanMsg()). The return value of the function is of no consequence.

handle_pr

: DINT;

handle_pr = DefineCanMsg(1, 1014, 1114, 32);

ClearCanMsg(handle_pr);

8.8.6.6

ReadCanMsg (only ETCxM)

FUNCTION ReadCanMsg: INT

VAR_INPUT

handle_pr

: DINT;

(* Handle on the management structure *)

dest_pr

: DINT;

(* Address to the data structure *)

END_VAR

With this function a CAN message can be read from the reception buffer. The
reception buffer is implemented as FIFO. The structure for reception data is
as follows:

TYPE CAN_MSG_TR

STRUCT

cobid_w

: WORD;

size_b

: BYTE;

rtr_bit

: BOOL;

data_ab

: ARRAY [0..7] OF BYTE;

END_STRUCT

END_TYPE

The variable dest_pr must always be given the address of a variable of type
CAN_MSG_TR (see example). This function will provide an immediate
return in any case. The meaning of the return values can be found in the
following table.

Return value

Meaning

−2

Invalid handle

0

No new message in FIFO

1

New message available, no further message in FIFO

2

New message available and further messages in FIFO

Declaration

Description

Example

Declaration

Description

Advertising