Custom Communication Protocol API
Custom communication scripting can be activated by a boolean VT entry that can be accessed in the DataMan Setup
Tool.
The methods are encapsulated in a communication object. Each communication channel creates an instance of the
communication object.
When the Custom Protocol Communication API is enabled through a private DMCC command, the scripting context adds
the following capabilities and requirements:
The constructor function of the communication object, CommHandler, contains a list of functions that the script
l
must contain:
onConnect
n
onDisconnect
n
onExpectedData
n
onTimer
n
onUnexpectedData
n
onError
n
onEncoder
n
The user must implement these functions, as the custom communications function will call them.
There are five member functions that the reader script engine offers, implemented by the reader:
l
send
n
close
n
setTimer
n
expectFramed
n
setEncoder
n
By using these functions, a user could write javascript code that allows the reader to interact with another system. In
particular, the user can write code to send messages back to the other system, something that is not supported in basic
scripting.
Advantage
The script engine uses the same context for function execution and object creation. This allows the sharing of data
between the script-based formatting and the custom communication scripts using global accessible objects.
List of functions
The communication member functions define the following method prototypes to be implemented by the user:
CommHandler – The constructor function for the communication object. The constructor must return a new
communication handler object implementing the user methods in the communication script. The reader methods are
added to the communication handler object directly after construction. The implementation of the constructor is
mandatory and an error will be thrown if it does not exist. Since software version 5.5 the constructor function call offers
the following argument:
localName: The local name of the connection. The local name of a network connection is "<READER_
o
IP>:<PORT>". An example for a Telnet connection is "10.82.80.156:23" with the default telnet port of 23. An
example for a Network Client connection is "10.82.80.156:57350". The local name for the serial connection is
DataMan Application Development
53
Need help?
Do you have a question about the DataMan and is the answer not in the manual?