beautypg.com

Build considerations, C conditional compilation – ThingMagic Mercury API v1.23.0 User Manual

Page 97

background image

Build Considerations

C Language Interface

97

Build Considerations

The full source code of the C API is provided. The API source code includes sample build
processes for desktop and embedded environments (Makefile and Visual Studio project).
It is recommend these be used as starting points for building custom applications.

Client code only needs to include a single header file, tm_reader.h to use the API.

API Changes Required for Different Hardware Platforms

The API has a couple layers of encapsulation. The important layer for porting purposes,
when dealing with serial communications based modules, is the transport layer which
handles the host/controller and reader communications. This involves sending
commands to and listening for/receiving responses from the module. This layer is
platform specific and is contained in the serial_transport_[posix|win32|dummy].c file.

To make the API work for your hardware architecture, you need to take the empty version
of these functions in serial_transport_dummy.c and write your own Serial/UART
commands (modeled after one of the prototypes provided for Windows or Posix systems)
to make sure the specified arguments are passed and provide the correct returns/
exceptions. 

The higher levels of encapsulation take care of encoding/decoding the reader commands.
There is no need to worry about header, length, checksum, etc., simply send that array
out over the serial interface and listen for the response.

For more details on building and porting the C API on different platforms, particularly
Win32, see the two README files in [SDK install dir]/c, README.PORTING and
README.WIN32.

C Conditional Compilation

For very storage-constrained systems, the C implementation provides compilation
conditionals to selectively remove parts of the system. Edit tm_config.h to comment out
the #defines of features you do not want.

For descriptions, see Mercury C API

Language Specific Reference Guides

for tm_config.h

#define TMR_ENABLE_SERIAL_READER

#define TMR_ENABLE_SERIAL_TRANSPORT_NATIVE

#define TMR_MAX_SERIAL_DEVICE_NAME_LENGTH 64