msLoggerRead (Function)

Top  Previous  Next

Architecture:

NX32L

Firmware version:

1.50.00


Read a data set from the specified inactive logger buffer.

 

Input:

Logger : SYSHANDLE

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

 

Data : PTR

A pointer to a structure to read the sensor data into. The structure type must be according to the data being read. See msLoggerNext for how to get the structure type.

 

Returns: INT

1


- Success.

0


- This function is not supported.

-1


- Interface is not open. Call msOpen first.

-2


- Generic error.

-4


- Illegal input data type.

-5


- The logger is not present.

-9


- The specified logger is running. Call msLoggerStop first.

-16


- Logger buffer error.

 

 

Declaration

FUNCTION msLoggerRead : INT;
VAR_INPUT
   Logger     : MANDATORY SYSHANDLE;
   Data       : PTR;
END_VAR;
 

Example:

VAR
  acc          : msAccData;
  gyr          : msGyrData;
  timestamp    : msTimestamp;
END_VAR;
 
FUNCTION readLogger;
VAR_INPUT
   _logger : SYSHANDLE;
END_VAR;
VAR
   next         : INT;
   rc           : INT;
END_VAR;
REPEAT
   next := msLoggerNext(logger:=_logger);
   CASE next OF
      _MS_LOGGER_NODATA:
         DebugMsg(message:="No more data in buffer!");
      _MS_LOGGER_TIMESTAMP:
         rc := msLoggerRead(logger:=_logger, data:=ADDR(timestamp));
         DebugFmt(message:="Timestamp: \4", v4:=timestamp.time);
         DebugMsg(message:="--------------------------------");
      _MS_LOGGER_ACCDATA:
         rc := msLoggerRead(logger:=_loggerdata:=ADDR(acc));
         DebugMsg(message:="  ACC >>> X: "+floatToStr(v:=(acc.x*1000.0))+" mg  Y: "+
                       floatToStr(v:=(acc.y*1000.0))+" mg  Z: "+
                       floatToStr(v:=(acc.z*1000.0))+" mg");
      _MS_LOGGER_GYRDATA:
         rc := msLoggerRead(logger:=_loggerdata:=ADDR(gyr));
         DebugMsg(message:="  GYR >>> X: "+floatToStr(v:=(gyr.x))+" dps  Y: "+
                       floatToStr(v:=(gyr.y))+" dps  Z: "+
                       floatToStr(v:=(gyr.z))+" dps");
   ELSE
      DebugFmt(message:="Invalid record ID \1", v1:=next);
   END_CASE;
   IF rc <> 1 THEN
      DebugFmt(message:="msLoggerRead (rc=\1)", v1:=rc);
   END_IF;
UNTIL (next = _MS_LOGGER_NODATA);
END_REPEAT;
END_FUNCTION;