FileReadBinData
Function Block - Read binary data from a file.
Inputs
Input |
Data Type |
Range |
Unit |
Default |
Description |
---|---|---|---|---|---|
Execute |
BOOL |
FALSE, TRUE |
N/A |
No default |
On the rising edge, read the size of a file. |
ID |
UDINT |
N/A |
N/A |
No default |
The ID of the open file. |
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 |
FALSE, TRUE |
N/A |
If TRUE, the command completed successfully. |
Error |
BOOL |
FALSE, TRUE |
N/A |
If TRUE, an error has occurred. |
ErrorID |
DINT |
|
|
Indicates the error if Error output is TRUE. See the table in File and TCP/IP Function Block ErrorIDs. |
NbRead |
DINT |
|
|
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