FP_SD_READ_LINE

Read one line from a specified file from SD card

This FP instruction reads the file specified by s_FullFileName from the pointer position specified by d2_dutReadLine up to a specified maximum number of bytes or until a line feed character (CR, LF, CR+LF) is detected. The result is stored in the area specified by d1_Out.

Parameters

Input

s_FullFileName (STRING)

File name

Input/output

d2_dutReadLine (FP_SD_READ_LINE_DUT)

Pointer position and maximum number of characters to be read

Output

d1_Out (STRING)

Output area

Remarks

  • Please also refer to precautions for SD card access.

  • The SD memory access active flag (sys_bIsSDMemoryAccessActive) turns to TRUE after the trigger EN of the SD card instruction has turned to TRUE and remains TRUE until execution has completed. During this time, other SD card instructions cannot be executed.

  • The SD memory access done flag (sys_blsSDMemoryAccessDone) is FALSE when the instruction is executed and turns to TRUE and remains TRUE when the instruction is completed.

  • Do not read the data from the output area until execution of the instruction is completed.

Error flags

sys_bIsSDMemoryAccessError
  • FALSE: when the instruction has completed without error

  • TRUE: when the instruction has completed with an error

  • Use sys_iSDMemoryAccessErrorCode to evaluate the error code.

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if the area specified using the index modifier exceeds the limit.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if the area specified using the index modifier exceeds the limit.

Example

POU header

All input and output variables used for programming this function have been declared in the POU header.The same POU header is used for all programming languages.

	VAR
		bStart: BOOL:=FALSE;
			(*activates the instruction*)
		dutSDReadString: FP_SD_READ_LINE_DUT;
		sStringRead1: STRING[32]:='';
		@'': @'';
	END_VAR

POU body

When the variable bStart changes from FALSE to TRUE, the function is carried out.

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 4 ;
        NETWORK_BODY
B(B_CONTACT,,bStart,5,1,7,3,R);
B(B_VAROUT,,dutSDReadString.udiReadCharPosition,16,2,18,4,);
B(B_VARIN,,0,8,2,10,4,);
B(B_F,E_MOVE!,,10,0,16,4,,?DEN?D?AENO?C);
L(1,2,5,2);
L(7,2,10,2);
L(1,0,1,4);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 8 ;
        NETWORK_BODY
B(B_VARIN,,'\TestLine.csv',10,4,12,6,);
B(B_CONTACT,,bStart,2,1,4,3,R);
B(B_CONTACT,,sys_bIsSDMemoryAccessActive,10,1,12,3,N);
B(B_VARIN,,dutSDReadString,10,5,12,7,);
B(B_VAROUT,,sStringRead1,27,4,29,6,);
B(B_F,FP_SD_READ_LINE!,,12,2,27,7,,?DEN?Ds_FullFileName?Dd2_dutReadLine?Ad2_dutReadLine?AENO?Cd1_Out);
L(1,2,2,2);
L(4,2,10,2);
L(12,2,12,4);
L(1,0,1,8);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF DF(bStart)And not sys_bIsSDMemoryAccessActive then
    dutSDReadString.udiReadCharPosition:=0;
    FP_SD_READ_LINE(s_FullFileName := '\TestLine.csv',
                    d2_dutReadLine := dutSDReadString,
                    d1_Out => sStringRead1);
END_IF;

Modified on: 2024-03-06Feedback on this pagePanasonic hotline