canLoggerSetup (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

MX2 pro, DX4 pro, CX1 pro-c/warp-c, MX2 turbo/encore/warp, NX-200, NX-400, LX2, LX5

Firmware version:

2.50 / 1.00.00


This function will initialize a buffer where received CAN messages are logged.

The logging to the buffer is started with the canLoggerStart function.

 

The logger can operate in two modes - with and without time information.

Only filtered messages are logged.

 

 

Input:

port : SINT (1/2) (default 1)

The port of the logger.

 

buffer : PTR

Address of buffer that is used to store the logged values.

 

Size : DINT (13..2147483647)

Size of buffer area in bytes.

 

Mode : SINT (default 1) (mode 2 is only supported on NX32/NX32L, requires firmware V4.69 / R1.11.00 or newer)

1

The logger will store CAN messages. (ID, size and 8 bytes data)

2

The logger will store CAN messages with time-stamp (time-stamp, ID, size and 8 bytes data)

 

The logger time-stamp, available in mode 2, is the number of milliseconds since the previous record in the log.

The time-stamp in mode 2 is stored as an INT type (16 bit), with the following semantics:

 

0 = first record.

1 = time since previous record <=1 ms.

1..32767 = number of milliseconds since previous record.

-1 = number of milliseconds since previous record is > 32767 milliseconds.

 

 

 

Returns: INT

0

- Success.

1

- Logger is running.

2

- Invalid argument.

3

- Invalid logger index.

 

Declaration:

FUNCTION canLoggerSetup : INT;
VAR_INPUT
  port   : SINT := 1;
  buffer : PTR;
  size   : DINT;
  mode   : SINT := 1;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
VAR_INPUT
  LogBuf : ARRAY [1..1300] OF SINT;
END_VAR;
 
PROGRAM CANExample;
 
// Open can
canOpen(baud := 250);
canLoggerSetup(buffer := ADDR(LogBuf), size := SIZEOF(LogBuf));
...
 
BEGIN
  ...
END;
END_PROGRAM;