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

Page 108

Advertising
background image

Custom Serial Transport Naming

108

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 C#.

class Program

{

static void Main(string[] args)

{

……

Reader.SetSerialTransport("tcp",SerialTransportTCP.CreateSerialReader

);

// Add the custom transport scheme before calling Create().

// This can be done by using C# API helper function

SetSerialTransport().

// It accepts two arguments. scheme and serial transport factory

function.

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

we are using the scheme "tcp".

// Factory function:custom serial transport factory function

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

readerIP:portnumber.

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

………

}

}

In the “cs\Sample\Codelets” directory, there is source code for this example, in the
ReadCustomTransport subdirectory, which shows how to enable reading over a “tcp”
custom serial transport layer (created by SerialTransportTCP.cs in the
cs\ThingMagicReader directory).

Advertising