Stream:startasyncinput(afunction, options), Stream:stopasyncinput() – ClearOne Writing StreamNet User Manual
Page 38
Writing StreamNet Device Drivers
9-8
All specifications subject to change without notification. All rights reserved. Copyright © 2007 NetStreams
Main +1 512.977-9393 / fax +1 512.977.9398 / Toll Free Technical Support +1 866-353-3496
3600 W. Parmer Lane, Suite 100; Austin, TX 78727 /
www.netstreams.com.
NOTE
NOTE
stream:startAsyncInput(aFunction, options)
Mixing synchronous
input via read and
asynchronous input via
startAsyncInput will
yield inconsistent and
variable results. If
mixing is required,
async input should
always be stopped via
stopAsyncInput before
read is used.
Enables asynchronous input on the associated stream. Has completed “messages” are
received aFunction will be invoked with the stream and message as parameters. The
options parameter contains an optional table that can be used to define a “message”:
The options parameter is in the form of a table, such as:
Stream:startAsyncInput(onInput, {
endString = “\r”,
trailing = 2
})
Asynchronous input is
not truly asynchronous
as the input function
will never interrupt
execution of an
asynchronous stream
handler, command
handler, or timer
handler.
stream:stopAsyncInput()
Stops asynchronous input previously started with startAsyncInput.
Key
Default
Notes
endString
Nil
If non-nil defines a string which will be used to recognize the end of a
message. Common values might be “\r”, “\n”, or “\r\n” Completed
messages will contain all the data between endString terminators and the
terminator itself.
timeout
0
If > 0 specifies the maximum time to wait for any input. Every “timeout” ms
any available data will be passed to the input function.
readIdle
0
If > 0 specifies the maximum time to wait while no data is being received. If
the readIdle timeout elapses with no new data being received any available
data will be passed to the input function.
maxRead
1024
The maximum # of characters to process before invoking the input
function.
trailing
0
If > 0 specifies that additional data should be returned after a message has
be recognized based on an endString. So specifying an endString of “\n”
and a trailing of 2 would return the all text up to and including the newline
and the following two characters.