msLoggerCreate (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

NX-200, LX2

Firmware version:

1.50.00


This function will establish a logger that can be used to log motion sensor data into a user provided buffer.

The detailed configuration of the established logger is done with the functions msLoggerAddAcc, msLoggerAddGyr and msLoggerAddMag.

One can only have a maximum of 8 loggers at a time.

 

Data from a logger will always deliver a full set as the first set, and then depending on downsample values will deliver partial sets.

With downsampling on the accelerometer at 1, gyroscope 2 and magnetomter 3, the data received will look like:

 

   Gyroscope sets  

   Acceleromter sets  

   Magnetometer sets  

   Time  

GYR0

ACC0

MAG0

T0

 

ACC1

 

T1

GYR1

ACC2

 

T2

 

ACC3

MAG1

T3

GYR2

ACC4

 

T4

 

ACC5

 

T5

GYR3

ACC6

MAG2

T6

...

...

...

...

 

When switching loggers, the first set will be a full set again.

 

In case there is no sensor sets for a given time, the timestamp will not be included, thus there can not be two successive timestamps.

 

Input:

Logger : SYSHANDLE

A user provided handle to uniquely identify the logger. See SYSHANDLE page. This field is mandatory.

 

Buffer : PTR

A pointer to the user provided buffer.

 

Size : DINT

Size in bytes of the user provided buffer. The size of the buffer must be at least 400 bytes for a cyclical buffer and otherwise at least 4000 bytes.

 

StopOnFull : BOOL (default FALSE)

If true, the buffer will stop collecting data when there is no more space for further data records in the buffer. Otherwise the buffer will function as a ring buffer.

 

Returns: INT

1

- Success.

0

- This function is not supported.

-1

- Interface is not open. Call msOpen first.

-2

- Generic error.

-3

- Invalid configuration.

-7

- The maximum amount of loggers are present.

-8

- The logger was already established.

 

Declaration

FUNCTION msLoggerCreate : INT;
VAR_INPUT
  Logger       : ACCESS SYSHANDLE;
  Buffer       : MANDATORY PTR;
  Size         : MANDATORY DINT;
  StopOnFull   : BOOL := FALSE;
END_VAR;
 

Example:

// For a more complete example, see example under msReadEvent
INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  logger       : SYSHANDLE;
  buf         : ARRAY[1..10000] OF DINT;
  rc           : INT;
END_VAR;
rc := msOpen();
DebugFmt(message:="msOpen (rc=\1)", v1:=rc);
...
rc := msLoggerCreate(logger:=logger, buffer:=ADDR(buf), size:=SIZEOF(buf), stoponfull:=TRUE);
DebugFmt(message:="msLoggerCreate (rc=\1) buffer_size=\4, stoponfull=TRUE", v1:=rc, v4:=SIZEOF(buf));
...
BEGIN
  ...
END;
END_PROGRAM;