beautypg.com

Example, Example 112 – ThingMagic Mercury API v1.23.0 User Manual

Page 112

background image

Custom Serial Transport Naming

112

Advanced Customization

Example

In MercuryAPI we have added support for a TCP serial bridge. The TCP serial bridge
allows the user to connect to a serial reader using TCP/IP and a port number. We have
added the custom transport file for TCP serial bridge. The following code example shows
how to implement it in Java.

class CustomTransport

{

public static void Main(string[] args)

{

……

Reader.setSerialTransport("tcp",new SerialTransportTCP.Factory());

// Add the custom transport scheme before calling Reader.create()

// This can be done by using function Reader.setSerialTransport()

// It accepts two arguments. scheme and Factory object.

// scheme: the custom transport scheme name. For demonstration

// purposes, we are using scheme "tcp".

// Factory object: reference to the serial transport.

// Call Reader.Create() method with reader URI as tcp://

readerIP:portnumber.

Reader.create(“tcp://172.16.16.146:1001”);

………

}

}