beautypg.com

Changes required for c – ThingMagic Mercury API v1.23.0 User Manual

Page 109

background image

Custom Serial Transport Naming

Advanced Customization

109

Changes Required for C

Starting with version 1.23.0 of the MercuryAPI SDK, we have added a serial transport
dispatch table to store the transport scheme name and factory init functions.

We have also modified the TMR_create() to use the dispatch table for serial readers.

So in order to use a new transport layer, the user needs to touch the Mercury C API in
one place only: In TMR_Serial_transport.h, you will need to add the prototype of the
factory init function.

typedef TMR_Status (*TMR_TransportNativeInit)(TMR_SR_SerialTransport

*transport, TMR_SR_SerialPortNativeContext *context, const char

*device);

TMR_Status TMR_setSerialTransport(char* scheme,

TMR_TransportNativeInit nativeInit);

main ()

{

……

ret = TMR_setSerialTransport(“Custom scheme name”, &”reference to

the factory init func”);

}

In the “c\src\samples” directory, there is source code for this example,
readcustomtransport.c, which shows how to enable reading over a “tcp” custom serial
transport layer (created by serial_transport_tcp_win32.c and serial_transport_tcp_posix.c
in the c\src\api directory).