mbusDataRequest (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

LX4

Firmware version:

1.94.00


This function is used to request data from a wired M-Bus slave.

The slave information can be read with mbusRecordSlaveInfo.

The meter data can then be read using mbusRecordGetInfo.

 

Input:

handle : SYSHANDLE

A handle to the connection

 

pri_addr : INT default -1

The primary address for the slave. Use -1 to use the secondary address instead.

 

sec_addr : STRING

The secondary address for the slave. Used if the primary address is  -1.

 

 

Returns: INT

1

- Success

0

- Not supported

-1

- Invalid handle

-5

- Invalid interface type.

-6

- Invalid address

-9

- Communication error

 

Declaration:

FUNCTION mbusDataRequest : INT;
VAR_INPUT
  handle   : SYSHANDLE;
  pri_addr : INT := -1;
  sec_addr : STRING;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  mb   : SYSHANDLE;
  rc   : INT;
  info : mbusRecordSlaveInfo;
END_VAR;
 
  ...
  // Open wired M-Bus interface @2400 baud
  rc := mbusOpen(handle := mb);
  ...
BEGIN
  // Request data from device
  rc := mbusDataRequest(handle := mb, pri_addr := 11);
  DebugFmt(message := "mbusDataRequest=\1", v1 := rc);
 
  info(handle:=mb);        
  IF info.ready THEN
    DebugFmt(message:="Info for \4:", v4:=info.id);
    DebugFmt(message:=" Enc:  \1", v1:=info.enc_state);
    DebugFmt(message:=" Man:  " + info.manufacturer);
    DebugFmt(message:=" Ver:  \1", v1:=info.version);
    DebugFmt(message:=" Med:  \1", v1:=info.medium);
    DebugFmt(message:=" AN :  \1", v1:=info.accessnumber);
    DebugFmt(message:=" Sta:  \1", v1:=info.status);
    DebugFmt(message:=" Addr: " + info.sec_addr);
    DebugFmt(message:=" Sig:  \1", v1:=info.signal);
  ELSE
    DebugMsg(message:="no response");
  END_IF;
  ...
END;
END_PROGRAM;