FileReadBinData

PLCopen motion icon

 Function BlockClosed A function block groups an algorithm and a set of private data. It has inputs and outputs. - Read binary data from a file.

Inputs

Input

Data Type

Range

Unit

Default

Description

Execute

BOOL

0, 1

N/A

No default

On the rising edgeClosed The transition of a digital signal from low to high. AKA: positive edge., read the size of a file.

ID

UDINT

N/A

N/A

No default

The ID of the open file.

FrameClosed In networking dialect, a message is called a frame.

USINT[ ]

N/A

N/A

No default

Where the binary data is stored.

FrameSize

DINT

N/A

N/A

No default

Number of bytes to store in the Frame array.

Outputs

Output

Data Type

Range

Unit

Description

Done

BOOL

 

 

If TRUE, the command completed successfully.

Error

BOOL

 

 

If TRUE, an error has occurred.

ErrorID

DINT

 

 

Indicates the error if Error output is TRUE.

See the table in Search IndexFile and TCP/IP Function Block ErrorIDs.

NbRead

STRING

 

 

The number of bytes read from the file.

Remarks

  • FileReadBinData stops reading from the file if it fills the passed Frame array, reads FrameSize bytes, or encounters the end of file, whichever comes first.
  • After a successful call to FileReadBinData, use SerializeIn to extract variable data from the binary data read from a file.

Figure 1: FileReadBinData

FBD Language Example

Not available.

FFLD Language Example

Not available.

IL Language Example

Not available.

ST Language Example

(* FileReadBinData example *)
CASE StepCounter OF
0:
  Inst_FileReadBinData(TRUE, MyInputFileID, InputFrame, 128);
  StepCounter := StepCounter + 1;
1:
  Inst_FileReadBinData(TRUE, MyInputFileID, InputFrame, 128);
  IF Inst_FileReadBinData.Done THEN
     BytesRead := Inst_FileReadBinData.NbRead;
     Inst_FileReadBinData(FALSE, 0, InputFrame, 0);
     StepCounter := StepCounter + 1;
  END_IF;
END_CASE;

See Also