FB_BinaryReader

 

FB_BinaryReader - General Information

Overview

Type:

Function block

Available as of:

V1.0.3.0

Inherits from:

-

Implements:

-

Versions:

Current version

Task

Efficient reading of any data structures from a binary file.

Description

The function block reads the number of bytes specified in i_diBufferSize from a file which was first created with FB_BinaryWriter and saves that which was read in memory at the address specified by i_dwBufferAdr. Sufficient memory must be reserved at the position of i_dwBufferAdr.

Reading is started with a positive edge at i_xExecute and stopped after an error is detected or after all data has been read successfully. During reading, no parameter (other than i_xExecute) may be changed. Also, that memory area which i_dwBufferAdr points to may not be written to.

Interface

Input

Data type

Description

i_xExecute

BOOL

FALSE -> TRUE: POU is activated. The reading process begins.

i_sFileName

STRING[80]

Name of the text file where the variable should be read from.

i_diBufferSize

DINT

Number of bytes to be read

i_dwBufferAdr

DWORD

Address of the array where the data should be stored. The respective amount of memory must be reserved.

Output

Data type

Description

q_xBusy

BOOL

TRUE: Reading is in progress.

q_xDone

BOOL

Reading is completed.

q_etDiag

GD.ET_Diag

General library-independent statement on the diagnostic.

A value not equal to ET_Diag.Ok corresponds to an diagnostic message.

q_etDiagExt

ET_DiagExt

POU-specific output on the diagnostic.

q_etDiag = ET_Diag.Ok -> Status message

q_etDiag <> ET_Diag.Ok -> Diagnostic message

Diagnostic Messages

q_etDiag

q_etDiagExt

Enumeration value

Description

OK

Executing

128

Version

OK

WaitForExecute

180

Wait for execution.

FileHandlingInvalid

FileNotExisting

104

The file does not exist.

FileHandlingInvalid

FileReadingInvalid

106

Error detected when reading from file.

FileHandlingInvalid

TooManyFilesOpen

105

Too many files are opened.

UnexpectedProgramBehavior

UnexpectedFeedback

1

An unintended detected error occurred during execution.

Executing

Enumeration name:

Executing

Enumeration value:

128

Description:

Version

The data is being read.

FileNotExisting

Enumeration name:

FileNotExisting

Enumeration value:

104

Description:

The file does not exist.

Issue

Cause

Solution

-

The file does not exist.

Copy the file to the flash disk of the controller.

-

At the input i_sFilename, a file name has been applied that does not exist.

Verify the file name at i_sFilename.

FileReadingInvalid

Enumeration name:

FileReadingInvalid

Enumeration value:

106

Description:

Error detected when reading from file.

Issue

Cause

Solution

-

The file is damaged.

Create the file again.

TooManyFilesOpen

Enumeration name:

TooManyFilesOpen

Enumeration value:

105

Description:

Too many files are opened.

Issue

Cause

Solution

-

Too many files are opened.

Close files that are no longer needed using SystemInterface.FC_CloseFile.

UnexpectedFeedback

Enumeration name:

UnexpectedFeedback

Enumeration value:

1

Description:

An unintended detected error occurred during execution.

Issue

Cause

Solution

-

An error occurred in the internal execution.

An error occurred in the internal execution.

WaitForExecute

Enumeration name:

WaitForExecute

Enumeration value:

180

Description:

Wait for execution.

The function block is ready. As reaction to a positive edge from i_xExecute, the data are read out.