Home  Contents

New BiS handler

Bis Core4 Lua Event System

SYNOPSIS

  1. bishandle = bis.newmaster(app, devicename_or_handle [, speed])
  2. bishandle = bis.newslave(app, devicename_or_handle [, speed])
  3. bishandle = bis.newpeer(app, devicename_or_handle [, speed])
  4. bishandle:close()

DESCRIPTION

Create a new BiS event handler. The handler is attached to the event processor passed in app.

There are three possibilities to create a BiS link. See the introductory document for a discussion.

If a string is passed as second parameter devicename_or_handle, this must be the device name of a serial port, the optional speed parameter selects the port speed, which defaults to 115200bps.

Passing a file handle as second parameter allows using an already open handle, for example a network connection. When the file handle is a serial port, it is automatically configured for BiS (8N1), including the optional speed parameter. When no speed is given, the port speed is not changed.

The bis:close() will close the handle when no longer needed. The BiS handle becomes invalid. This automatically happens during garbage collection, but that takes an unknown amount of time. A serial port is closed only if it was opened by the BiS code.

RETURN VALUE

On success, a BiS event handler instance. On failure, three values are returned: nil, a string describing the error (The result of the C library call strerror() on the errno code) and the errno number from the standard C library.

EXAMPLE

>  > 
app = event.new() bis = bis.newmaster(app, "/dev/ttyS1", 38400)

SEE ALSO