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;
...
rc := mbusOpen(handle := mb);
...
BEGIN
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;
|