TableTracker Network API
Current version: 1.1
Files
Downloading
The files can be downloaded from the EVL subversion server:
svn co svn://cube.evl.uic.edu/lambdatracker/trackerapi [path]
Building and Installing
If you're writing a c/c++ application, its probably easiest just to grab tabletracker.h and tabletracker.c and compile them with your own source. However, you can also link with a static library or shared object.
- Static Library:
make static
- Shared Object:
change the PREFIX variable in Makefile
make
make install
make uninstall to get rid of it.
- Test Application:
make test
For Lua scripting, build and install the tabletracker Lua library as follows:
- Lua:
change the PREFIX variable in Makefile
make lua
make install-lua
make uninstall-lua to get rid of it.
To modify electro so that it loads the tabletracker Lua library do the following:
- Patching Electro:
Copy tabletracker-electro.diff to the electro root folder.
cd <electro root>
patch -Np0 -i tabletracker-electro.diff
make MPI=1 TABLETRACKER=1
C API
Really simple!
int TT_open(unsigned short port)
Opens a connection to listen for tracking messages on the given port.
Returns:
- TT_OK if everything went well.
- TT_ERR_SOCK if a socket could not be created.
- TT_ERR_BIND if error occured while binding socket.
int TT_poll(unsigned int timeout)
Checks for available messages.
Waits for the given number of milliseconds.
If a zero timeout is supplied, TT_poll will return immediately.
If a negative timeout is supplied, TT_poll will block until a message is received.
Returns:
- 0 if no messages are available.
- 1 if messages are pending.
int TT_get(int *id, double *xpos, double *ypos, double *angle, int *type)
Grabs the next tracker message. Nonblocking.
Parameters:
- id: the track ID. It's what identifies a particular device.
- xpos: x position of the track, from 0 to 1.
- ypos: y position of the track, from 0 to 1.
- angle: angle of the track in degrees.
- type: type of track. Indicates track state (buttons).
Returns:
- TT_OK if everything went well.
- TT_ERR_MESG if an invalid message was received.
void TT_close()
Closes the socket.
LUA Bindings
error TT.open(port)
Opens a connection to listen for tracking messages on the given port.
Returns:
- TT.OK if everything went well.
- TT.ERR_SOCK if a socket could not be created.
- TT.ERR_BIND if error occured while binding socket.
status TT.poll(timeout)
Checks for available messages.
Waits for timeout milliseconds.
If a zero timeout is supplied, TT.poll will return immediately.
If a negative timeout is supplied, TT.poll will block until a message is received.
Returns:
- nil if no messages are available.
- true if messages are pending.
status, id, xpos, ypos, angle, type TT.get()
Grabs the next tracker message. Nonblocking.
Returns:
- status: TT.OK if everything went well, TT.ERR_MESG if an invalid message was received.
- id: the track ID. It's what identifies a particular device.
- xpos: x position of the track, from 0 to 1.
- ypos: y position of the track, from 0 to 1.
- angle: angle of the track in degrees.
- type: type of track. Indicates track state (buttons).
TT.close()
Closes the socket.