self = port:setReadListener(readCallback[, object])
Registers a callback for read notifications. The callback is called after a read request. Returns self.
Parameter |
Type |
Description |
---|---|---|
port |
in port object |
The port to modify. |
readCallback |
in function |
Callback to receive read notifications. The actual value read can be retrieved with port:getValue(). |
object |
in any (optional) |
If an object is provided, it will be passed as the first parameter to the specified callback function. The object can be of any type except nil. |
self |
out port object |
The input port is returned as the output. |
Introduced in platform.apiLevel = '2.7'.
readCallback([object , ]port[, error])
This callback is called when a read request has been completed. A string is passed in case an error occurred while processing the read request. The actual value read can be retrieved with port:getValue().
Parameter |
Type |
Description |
---|---|---|
object |
in any (optional) |
If an object was provided as a parameter to the function setReadListener, it will be passed as the first parameter to this callback function. |
port |
in port object |
The port from where the data was requested to be read. |
error |
in string (optional) |
An error message if an error occurred while processing the read request; nil otherwise. |
Introduced in platform.apiLevel = '2.7'.