FileReadBinData
Description
This function block reads binary data from a file. FileReadBinData stops reading from the file if it fills the passed FrameIn networking dialect, a message is called a frame array, reads FrameSize bytes, or encounters the end of file, whichever comes first.
After a successful call to FileReadBinData, one may use SerializeIn to extract variable data from the binary data read from a file.
Figure 8-208: The FileReadBinData Function Block
Related Functions
FileClose, FileEOF, FileOpenA, FileOpenR, FileOpenW, FileReadLine, FileSeek, FileWriteBinData, FileWriteLine, SerializeIn
See also: File Management
Arguments
Input
Execute | Description | On the rising edgeA rising edge is the transition of a digital signal from low to high. It is also called positive edge read the size of a file. |
Data Type | BOOL | |
Range | 0, 1 | |
Unit | N/A | |
Default | — | |
ID | Description | ID of the open file. |
Data Type | UDINT | |
Range | N/A | |
Unit | N/A | |
Default | — | |
Frame | Description | Where the binary data will be stored |
Data Type | USINT[] | |
Range | N/A | |
Unit | N/A | |
Default | — | |
FrameSize | Description | Number of bytes to store in the Frame array. |
Data Type | DINT | |
Range | N/A | |
Unit | N/A | |
Default | — |
Output
Done | Description | If TRUE, then the command completed successfully |
Data Type | BOOL | |
Error | Description | If TRUE, an error has occurred |
Data Type | BOOL | |
ErrorID | Description | Indicates the error if Error output is set to TRUE. See the table in Search IndexFile and TCP/IP Function Block ErrorID Output |
Data Type | DINT | |
NbRead | Description | The number of bytes read from the file. |
Data Type | STRING |
Example
Structured Text
(* 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;