“COM1” or “COM USB”.
o
onConnect
– Initialize state upon connection (a network connection established or protocol stack starts on serial
connection). If the method is not implemented an error occurs. The method has one argument and a return value:
l
peerName
– The peer name of the connection. The peer name for a network connection is ”<PEER_
IP>:<PORT>”. An example peer name for a Telnet connection is “10.82.80.71:19772”, for a “Network
Client” connection it is “10.82.80.71:1000”, where the host port is configured to 1000. The peer name for
the serial connection is “COM1” or “COM USB”.
l
return
– The boolean return value defines if the handler for this connection should be activated:
n
true: Enables customization of the communication protocol. Therefore, if you want to use your own
protocol for communicating with the Dataman device, return true.
n
false: If you do not need the customized protocol for this peer, return false.
o
onDisconnect
– Cleanup method called when closing the connection channel
o
onExpectedData
– Method called if data matching the set properties has arrived. The method has one argument:
l
inputString
– The received frame matched data excluding header and termination
l
return
– Determines if the data should be removed from input buffer
n
true: clear the buffer.
n
false: keep the value in buffer.
o
onTimer
– The timer value expired
o
onUnexpectedData
– The recieved data is not matching the requirements. The boolean return value determines
if the data should be removed from input. The method has one argument:
l
inputString – The received data
l
return – Determines if the data should be removed from input buffer
n
true: clear the buffer.
n
false: keep the value in buffer.
o
onError
– An error occurred in the firmware and can be reported. The implementation of the method is
mandatory. The method has one argument and no return value:
l
errorMsg
– The error message for trigger overruns (“Trigger Overrun”), buffer overruns (“Buffer Overflow”)
and general errors reported by the firmware.
o
onEncoder
– Executed if a configured encoder distance is reached. The distance can be configured by the
setEncoder
method. The method has no arguments or return value.
o
send
– Send data to channel, returns the number of send characters. The method must be called with one
argument:
l
Data argument is a string
o
close
– Actively terminates connection for the communication object (for example, close TCP/IP socket). On
UART, this causes
onConnect
to be called right afterwards.
o
setTimer
– Set the one-shot timer value when the onTimer will be executed. The timer can be re-initialized and
aborted.
l
Timeout in seconds of type double, internal resolution is us (1e-6 sec). A zero value aborts a running
timer. Active timer will be overwritten.
54
DataMan Application Development