This function will move the contents of the logger to memory.
In mode 1, the CAN messages will be stored in memory it the following format:
<xtd/size><ID><data>
In mode 2, the CAN messages will be stored in memory it the following format:
<xtd/size><ID><time><data>
Where:
xtd
|
4 bits
|
- Located in the upper nibble of the first byte; zero = standard identifier, other = extended identifier.
|
size
|
4 bits
|
- Located in the lower nibble of the first byte; the number of valid data bytes.
|
ID
|
4 Bytes
|
- The message identifier.
|
time
|
2 Bytes
|
- The timestamp. (Look here for information)
|
data
|
8 Bytes
|
- The message data.
|
Input:
port : SINT (1/2) (default 1)
The port of the logger.
dst : PTR;
Address of destination data area.
size : DINT;
The size of the memory in bytes.
Output:
None.
Returns: INT
>0
|
- Number of bytes written
|
-1
|
- Logger is not configured.
|
-2
|
- Illegal data found in logger.
|
Declaration:
FUNCTION canLoggerToMemory : INT;
VAR_INPUT
port : SINT := 1;
dst : PTR;
size : DINT;
END_VAR;
Example:
INCLUDE rtcu.inc
VAR
LogBuf : ARRAY [1..2600] OF SINT;
read : ARRAY [1..480] OF SINT;
END_VAR;
PROGRAM example;
VAR
FilterID : SINT;
level : INT;
rc : INT;
END_VAR;
canOpen(baud := 250);
FilterID := canFilterCreate(xtd := TRUE, startID := 16#0EFDD600, length := 6);
canLoggerSetup(buffer := ADDR(LogBuf), size := SIZEOF(LogBuf));
canLoggerStart();
...
BEGIN
...
canLoggerStart();
...
level := canLoggerLevel();
IF level >= 900 THEN
rc := canLoggerToMemory(dst := ADDR(read), size := SIZEOF(read));
IF rc > 0 THEN
...
END_IF;
END_IF;
...
END;
END_PROGRAM;
|