Home  Contents

BiS Introduction

Bis Core4 Lua Event System

DESCRIPTION

The BiS module provides event handling support for the Teratronik BiS protocol.

Call bis.newmaster(), bis.newslave() or bis.newpeer() to create a new event handler.

In master mode, this controller will initiate all communication. The master can talk to one or more slaves, which communicate only when requested by the master.

In slave mode, this controller waits for requests from a master and can send a response in reply.

The peer mode is only possible for a direct point-to-point connection, e.g. a network socket or direct RS232 serial link. Only two devices can communicate over this link. Both devices are master and slave at the same time. Any one of both devices can send a query(master) packet to the other where the other must reply as a slave. So this connection is actually two links in one. This is possible since a query packet has a different start code from a response packet, so both won't interfere.

Slave mode addresses are configured using bis:setAddress(), bis:address(). It is possible to run a BiS connection without an address, but then only one slave device can be used. The peer mode is typically run without addresses.

In master mode (or peer mode while acting as a master), it is necessary to set up retries and timeouts. The commands for this are bis:setRetryInterval() and bis:setRetryCount().

In case of an error, the link can be controlled with bis:stopRetries() or bis:resetSequence().

A master (or peer acting as a master) sends a query using bis:sendQuery(). A slave (or peer acting as a slave) responds using bis:sendResponse(). The optional command bis:sendAck() sends an empty response.

Incoming data is reported with callbacks, depending on mode and data content.

bis.query() Called in slave or peer mode when the remote side has send a query packet.
bis.queryMTD16() Called in slave or peer mode when the remote side has send a query packet that contains MTD16 encoded data. The callback bis.query() is not called in that case.
bis.response() Called in master or peer mode when the remote side has responded to a query.
bis.responseMTD16() Called in master or peer mode when the remote side has responded to a query with a packet that contains MTD16 encoded data. The callback bis.response() is not called in that case.
bis.timeout() Called in master mode when there is no answer from the slave after all retries have been exhausted.