You are here: Lua Scripting Resources eGuide > Lua Scripting API Reference Guide > ASI Library > read

21.7.11 read

error = port:read([bytesToRead])

Sends an asynchronous request for a read operation. When the request is serviced, the readCallback is called to confirm completion, if previously specified with setReadListener. Returns error if an error occurred.

Parameter

Type

Description

port

in port object

The port to read from.

bytesToRead

in number

Amount of bytes to read. Must be in the interval [1..1024]. By default 1024 is used if no amount is specified.

error

out string (optional)

If request is successfully queued up, nil is returned; an error message otherwise.

Introduced in platform.apiLevel = '2.7'.