For the complete documentation index, see llms.txt. This page is also available as Markdown.
Page cover

MTDevice Class Methods

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.

requestDeviceList

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

connectionType

MTConnectionType value: MTConnectionType.USB, MTConnectionType.IP, MTConnectionType.Serial

Return Value: None

setConnectionType

This method sets the connection type of the device..

public void setConnectionType(MTConnectionType connectionType)

Parameters:

Parameter

Description

connectionType

MTConnectionType value: MTConnectionType.USB, MTConnectionType.IP, MTConnectionType.Serial

Return Value: None

setAddress

This method sets the address of the device.

Parameters:

Parameter

Description

deviceAddress

String value of the address.

The following table shows the address formats supported by the different connection types:

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]

The IP address of the device in dotted-quad notation (i.e. 192.178.1.123).

IP

[PORT]

The TCP port of the device. (Default: 5000)

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)

[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)

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)

Return Value: None

setDeviceID

This method sets the device ID.

Parameters:

Parameter

Description

deviceID

String value of the device ID.

Return Value: None

openDevice

This method opens the connection to the device.

Parameters: None

Return Value: None

closeDevice

This method closes the connection to the device.

Parameters: None

Return Value: None

isDeviceConnected

This method returns whether the device is connected or not.

Parameters: None

Return Value:

Return true if the device is connected. Otherwise, return false.

sendDataString

This method sends a data string to the device.

Parameters:

Parameter

Description

dataString

Data to be sent in hexadecimal string format.

Return Value:

  • 0 = Success (MTDevice.SEND_SUCCESS)

  • 9 = Error (MTDevice.SEND_ERROR)

  • 15 = Busy (MTDevice.SEND_BUSY)

sendDataBytes

This method sends data bytes to the device.

Parameters:

Parameter

Description

dataBytes

Data to be sent in byte array format.

Return Value:

  • 0 = Success (MTDevice.SEND_SUCCESS)

  • 9 = Error (MTDevice.SEND_ERROR)

  • 15 = Busy (MTDevice.SEND_BUSY)

sendMTCMSMessage

This method sends a MagTek CMS message to the device.

Parameters:

Parameter

Description

message

MTCMSMessage to be sent to the device.

Return Value:

  • 0 = Success (MTDevice.SEND_SUCCESS)

  • 9 = Error (MTDevice.SEND_ERROR)

  • 15 = Busy (MTDevice.SEND_BUSY)

Last updated