mbusDataReceive (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

LX4,NX-400

Firmware version:

1.94.00


This function is used to receive data from a wireless 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

 

timeout : INT default 0

Number of seconds to wait for data from Wireless M-Bus. Use 0 seconds to return immediately if there is no data in the buffer.

 

filter : STRING

Specifies the address or address filter to receive frames from. If not specified, it will just receive the first frame in the buffer.

 

 

Returns: INT

1

- Success

0

- Not supported

-1

- Invalid handle

-5

- Invalid interface type.

-7

- Invalid filter.

-9

- Communication error

-10

- Timeout before data was received.

-14

- Invalid timeout value.

 

Declaration:

FUNCTION mbusDataReceive : INT;
VAR_INPUT
  handle   : SYSHANDLE;
  timeout : INT := 0;
  filter   : STRING;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  mb   : SYSHANDLE;
  rc   : INT;
  info : mbusRecordSlaveInfo;
END_VAR;
 
  ...
  // Open wireless M-Bus interface in T1+C mode
  rc := mbusOpen(type:=2, handle:=mb, mode:=_MBUS_MODE_T1_C);
  DebugFmt(message:="mbusOpen(): \1", v1:=rc);
  ...
BEGIN
  // Wait for 15 seconds for data from 1234567893153303
  rc := mbusDataReceive(handle:=mb, filter:="1234567893153303", timeout:=15);
  DebugFmt(message:="mbusDataReceive: \1", v1:=rc);
 
  IF rc = 1 THEN
    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);
    END_IF;
    ...
  END_IF;
 
  ...
END;
END_PROGRAM;