PRVREC (FB)ΒΆ
FUNCTION_BLOCK PRVREC
Note
The application program of the Field Device shall acknowledge the received request, otherwise the Host Controller will get a timeout error or the device stack will send a negative response.
Code-Example
PROGRAM ProvideData
VAR
    prvData : CommFB.PRVREC;
    data : ARRAY[0..3] OF BYTE := [0,1,2,3];        // some dummy data
END_VAR
// Variant 1: receive data for a specific slot:
prvData.EN := 1;
prvData.F_ID := CommFB.SUBSLOT_ID(EN := TRUE, PN_Device.DeviceID, 2, 1);    // get ID of Slot 2 of the specified device
prvData(MODE := CommFB.PRVREC_MODE.RECEIVE_BY_SLOT);        // get request
IF prvData.NEW THEN     // process record
    IF(prvData.SLOT = 1 AND  prvData.INDEX = 2) THEN
        prvData(MODE := 3, LEN:=4, RECORD := ADR(data));    // pos. response with data
    END_IF
END_IF
// Variant 2: check for request, then decide to process it (receive + pos./neg. response)
prvData(MODE := CommFB.PRVREC_MODE.CHECK, F_ID := PN_Device.DeviceID);  // get request
IF(prvData.NEW) THEN
    // Reject everything else.
    // If a request from the host is not confimed by the aplication, the stack may send a neg. response after a timeout.
    prvData(MODE := 4, CODE1 := 16#B2);
END_IF
- InOut:
- Scope - Name - Type - Comment - Input - EN- BOOL- Enable - MODE- UINT- Function specifier, see PRVREC_MODE - F_ID- DWORD- Slot / subslot to filter the data records to receive - CODE1- BYTE- Reason for negative response. (see ErrorCode1_RW) - CODE2- BYTE- Reason for negative response. (0 or user specific) - LEN- UINT- Length of a data record to provide - RECORD- POINTER TO BYTE - Provided data record - Output - ENO- BOOL- Function enabled - NEW- BOOL- New data record requested - STATUS- DWORD- Field Device interface status - SLOT- UINT- Slot the record is requested for - SUBSLOT- UINT- Subslot the record is requested for - INDEX- UINT- Index of the requested data record - RLEN- UINT- Length of the requested data record 
