After creating an instance of the MTDevice class in your software project, use the methods described in this section to communicate with MagTek CMS device.
This method initiates request to discover devices that are visible to the host using the specified connection interface. The OnDeviceList event will provide information regarding the available devices once the discovery process is completed.
public void requestDeviceList(MTConnectionType connectionType)Parameters:
Parameter
Description
Return Value: None
This method sets the connection type of the device..
Parameters:
Return Value: None
This method sets the address of the device.
Parameters:
The following table shows the address formats supported by the different connection types:
Return Value: None
This method sets the device ID.
Parameters:
Return Value: None
This method opens the connection to the device.
Parameters: None
Return Value: None
This method closes the connection to the device.
Parameters: None
Return Value: None
This method returns whether the device is connected or not.
Parameters: None
Return Value:
Return true if the device is connected. Otherwise, return false.
This method sends a data string to the device.
Parameters:
Return Value:
0 = Success (MTDevice.SEND_SUCCESS)
9 = Error (MTDevice.SEND_ERROR)
15 = Busy (MTDevice.SEND_BUSY)
This method sends data bytes to the device.
Parameters:
Return Value:
0 = Success (MTDevice.SEND_SUCCESS)
9 = Error (MTDevice.SEND_ERROR)
15 = Busy (MTDevice.SEND_BUSY)
This method sends a MagTek CMS message to the device.
Parameters:
Return Value:
0 = Success (MTDevice.SEND_SUCCESS)
9 = Error (MTDevice.SEND_ERROR)
15 = Busy (MTDevice.SEND_BUSY)
IP
[PORT]
The TCP port of the device. (Default: 5000)
[PARITY]
The parity checking protocol. (Default: NONE).
Supported Values: NONE,EVEN,ODD,SPACE,MARK
[STOPBITS]
The number of stop bits per byte. (Default: 1)
Supported Values: 1,1.5,2
[HANDSHAKE]
The handshaking protocol for serial port transmission of data.
(Default: NONE)
Supported Values: NONE,RTS,XONXOFF,RTSXONSOFF
[STARTINGBYTE]
The special character used as the starting byte for each message.
(Default is empty string)
An empty string indicates no special character is used as the starting byte for each message.
[ENDINGBYTE]
The special character used as the ending byte for each message.
(Default is 0x0A)
connectionType
MTConnectionType value: MTConnectionType.USB, MTConnectionType.IP, MTConnectionType.Serial
Parameter
Description
connectionType
MTConnectionType value: MTConnectionType.USB, MTConnectionType.IP, MTConnectionType.Serial
Parameter
Description
deviceAddress
String value of the address.
Connection Type
Address Format Parameter
Address Format Descroption
USB
[PATH]
The OS specific device path to the USB device. The path is normally retrieved from the Address property of MTDeviceInformation.
IP
[IPA]
Parameter
Description
Serial
PORT=[PORT],
BAUDRATE=[BAUDRATE],
DATABITS=[DATABITS],
PARITY=[PARITY],
STOPBITS=[STOPBITS],
HANDSHAKE=[HANDSHAKE],
STARTINGBYTE=[STARTINGBYTE],
ENDINGBYTE=[ENDINGBYTE],
CRCMODE=[CRCMODE]
Parameter
Description
[PORT]
The OS specific device path to the serial port (i.e. COM4).
[BAUDRATE]
The data baud rate . (Default: 9600)
[DATABITS]
The data bits per byte. (Default: 8)
Connection Type
Address Format
An empty string indicates no special character is used as the ending byte for each message
[CRCMODE]
A value of 0 indicates CRC is disabled, otherwise CRC is enabled.
(Default: 0)
Parameter
Description
deviceID
String value of the device ID.
Parameter
Description
dataString
Data to be sent in hexadecimal string format.
Parameter
Description
dataBytes
Data to be sent in byte array format.
Parameter
Description
message
MTCMSMessage to be sent to the device.
The IP address of the device in dotted-quad notation (i.e. 192.178.1.123).
public void setConnectionType(MTConnectionType connectionType)public void setAddress(string deviceAddress)public void setDeviceID(string deviceID)public void openDevice()public void closeDevice()public bool isDeviceConnected()public int sendDataString(string dataString)public int sendDataBytes(byte[] dataBytes)public int sendMTCMSMessage(MTCMSMessage message)