System_read block

Short summary

Name

System_read

→POU type

→function

Category

more system blocks, blocks for calling system functions, block with internal error diagnostic

Graphical interface

images/download/thumbnails/414780346/System_read-version-1-modificationdate-1534499591897-api-v2.png

Available since

  • version 1.13.0 (for logi.CAD 3) and version 2.3.901 of the →runtime system – initial variant: data as VAR_INPUT

    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/warning.svg This block is supported for →Raspberry Pi only.

  • version 1.54.0 (for logi.CAD 3) and version 3.0.9 of the →runtime system – enhancement: additional output rc, data as VAR_IN_OUT images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/warning.svg This block is supported for the built-in PLC

    and for Raspberry Pi only.

  • version 1.109.0 (for logi.CAD 3) and version 3.19.0 of the →runtime system
    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/warning.svg This block is supported for the built-in PLC

    , for Raspberry Pi
    and when using the platform LinuxX86 only.

  • version 2.0.4 (for library System) and version 3.23.0 of the →runtime system
    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/warning.svg This block is supported for the built-in PLC and when using the platform LinuxX86 .

    Moreover, the block is supported when using the following target systems: Raspberry Pi, →phyBOARD-Regor, →phyBOARD-Wega, →µMIC.200

  • version 2.0.5 (for library Standard) – graphical interface with in-out variable

Functionality

The block reads up to 64 bytes from a given file descriptor.

Required expertise

In order to use this block efficiently, you have to be familiar with the functionality of the underlying system call for the operating system used on the PLC.

Inputs, outputs, return value


Identifier

→Data type

Description

Inputs:

fd

DINT

the file descriptor

count

DINT

number of bytes to read in one go

In-outs
(VAR_IN_OUT):

data

ARRAY[0..63] OF BYTE

the read bytes

Outputs:

rc

DINT

return code:

  • 0 = no error

  • -2 = invalid number of bytes

  • -3 = failed system call

errno

DINT

error code returned by the system call

Windows standard values (valid for built-in PLC): see https://msdn.microsoft.com/en-us/library/t3ayayh1.aspx
Linux standard values (e.g. valid for Raspberry Pi): see http://www-numi.fnal.gov/offline_software/srt_public_context/WebDocs/Errors/unix_system_errors.html

Return value:

LINT

returns the return code of the read system call

Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.

See:

The output ENO of this block will only be value TRUE (or an equivalent), in case the given number of bytes has been read.

Internal error diagnostic for block

The block checks the following error cases:

  • The system service has not been loaded.

  • The return value of the block is a negative value.

  • The return code of the function call equates to an error (output rc ≠ value 0).

In such an error case, the output ENO of the block is set to value FALSE (or an equivalent).

Example for usage within ST-editor

At present, there is no example.

When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.