This function block will provide information about a slave.
For M-Bus this information must be requested with mbusDataRequest.
For Wireless M-Bus, the data must have been received with mbusDataReceive.
Input:
handle : SYSHANDLE
A handle to the connection
Output:
id : DINT
The device id / serial number of the slave.
manufacturer : STRING
The EN 61107 manufacturer ID as a string.
version : INT
The version number of the slave.
medium : INT
The medium of the received data.
pri_addr: INT
The primary address of the slave. -1 for wireless M-Bus.
sec_addr: STRING
The secondary address of the slave.
accessnumber : INT
The access number of the package.
enc_state: USINT
The encryption state of the package.
0
|
- Not encrypted
|
1
|
- Encrypted, decryption was successful.
|
2
|
- Decryption failed - the key may be wrong.
|
3
|
- Decryption key not found.
|
4
|
- Unknown encryption type.
|
signal : SINT
The signal strength of the package in dB. Only available for Wireless M-Bus. 0 if not available.
status: INT
Status field from slave.
ready : BOOL
TRUE if the information is available, FALSE if not.
Declaration:
FUNCTION_BLOCK mbusRecordSlaveInfo;
VAR_INPUT
handle : SYSHANDLE;
END_VAR;
VAR_OUTPUT
id : INT;
manufacturer : STRING;
version : INT;
medium : INT;
pri_addr : INT;
sec_addr : STRING;
accessnumber : INT;
enc_state : USINT;
signal : SINT;
status : INT;
ready : BOOL;
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;
|