Target Communication Framework: Lua Integration
Copyright (c) 2007-2019 Wind River Systems, Inc. and others. Made available under the EPL 2.0
Agent portion made available under your choice of EPL 2.0 or EDL v1.0 dual-license.
Direct comments, questions to the tcf-dev@eclipse.org mailing list
The TCF integration with Lua allows writing TCF client and server programs in the Lua programming language.
The integration is done so the main loop is the TCF event dispatch loop.
At startup a Lua program is invoked to allow an initial setup after which it should return to enter the TCF dispatch loop.
TCF functions are accessible from the Lua table named "tcf". Accessible functions are:
Function
| Callback
| Description
|
read_command(read_command_callback)
read_command_callback(string)
Reads one line from stdin or if the -s command line option is specified from the specified file.
|
peer = peer_server_find(peer_name)
NA
| Looks up peer object with the specified name. Returns nil if not found.
|
peers = peer_server_list()
NA
| Returns a table of discovered peer objects.
|
peer = peer_server_from_url(peer_url)
NA
| Creates a peer object from the specified URL.
|
protocol = protocol_alloc()
NA
| Created a new protocol object.
|
channel_connect(peer, protocol, connect_callback)
connect_callback(channel, errorString)
Creates connection to specified peer.
|
event = post_event(post_event_callback, micro_seconds)
post_event_callback()
The micro_seconds argument is optional. Then not present the callback function will be invoked after currently pending event have been processed.
| | | | | | | | | | |
Protocol object functions:
Function
| Callback
| Description
|
command_handler(protocol, service, name, command_callback)
command_callback(token, data)
Register command handler for service and name with protocol . The command_callback function will be called each time a command of the specified name and service is received on a channel associated with the protocol object.
| | |
Channel object functions:
Function
| Callback
| Description
|
close(channel)
NA
| Disconnects the specified channel.
|
connecting_handler(channel, connecting_callback)
connecting_callback()
Register callback function which is called when the channel enters connecting state.
|
connected_handler(channel, connected_callback)
connected_callback()
Register callback function which is called when the channel enters connected state.
|
receive_handler(channel, receive_callback)
receive_callback()
Register callback function which is called when the channel receives a message.
|
disconnected_handler(channel, disconnected_callback)
disconnected_callback()
Register callback function which is called when the channel is disconnected.
|
event_handler(channel, service, name, event_callback)
event_callback(data)
Register callback function which is called when an event for service and name is received.
|
start(channel)
NA
| Starts communication on channel.
|
send_command(channel, service, name, data, replay_callback)
replay_callback(data, error)
Send a command to channel and register callback when reply is received.
|
services = get_services(channel)
NA
| Create a table of service names supported by remote peer.
| | | | | | | | | | | | | | | |
Peer object functions:
Function
| Callback
| Description
|
id = getid(peer)
NA
| Return ID of peer.
|
getnames(peer)
NA
| Return table of peer propery names.
|
getvalue(peer, name)
NA
| Return value of propery name .
|
setvalue(peer, name, value)
NA
| Set value of propery name .
|
getflags(peer)
NA
| Return table of flags for peer.
|
setflags(peer, flags)
NA
| Set flags for peer.
| | | | | | |
Event object functions:
Function
| Callback
| Description
|
cancel(event)
NA
| Cancel event created by post_event() .
| |
Download and Build
The integration has only been tested on Linux at this point.
cd <luadir>
curl -O http://www.lua.org/ftp/lua-5.1.4.tar.gz
tar zxf lua-5.1.4.tar.gz
cd lua-5.1.4
make linux
make local
cd <tcfdir>/agent
make LUADIR=<luadir>/lua-5.1.4
./obj/GNU/Linux/i686/Debug/tcflua tcf_example.lua