UniPRT SDK v1.0.0.0
 
Loading...
Searching...
No Matches
TcpComm.TcpComm Class Reference

Public Member Functions

None __init__ (self, str ipAddress, int port)
 Initializes a new instance with the given IP address and port.
 
"TcpComm" from_descriptor (cls, str descriptor, DescriptorPortType port_type)
 Creates a TcpComm object from a descriptor string and port type.
 
None open (self)
 Opens the connection to the TCP server.
 
str get_ip_address (self)
 Gets the IP address of the remote server.
 
 connection_settings (self, ip_address, port)
 Configures connection settings with the specified IP address and port.
 
bool is_connected (self)
 A flag indicating whether the connection is established.
 
None close (self)
 Closes the connection to the TCP server.
 
None write (self, bytes text)
 Writes data to the TCP server.
 
Optional[bytes] read (self)
 Reads data from the TCP server.
 
None wait_for_data (self, int msTimeout)
 Waits for data to be available on the TCP connection.
 
Optional[bytes] write_and_wait_for_response (self, bytes text, int responseStartTimeout, int responseEndTimeout, str completionToken="")
 Writes data to the TCP server and waits for a response.
 
Optional[bytes] write_and_wait_for_response_json (self, bytes text, int responseStartTimeout, int responseEndTimeout, str completionToken="")
 Writes JSON data to the TCP server and waits for a response.
 
 write_printer_file (self, str fileName)
 Writes a file to the printer.
 
None send_printer_file (self, str ipAddress, str fileName)
 Sends a print file to the specified IP address.
 
None send_print_string (self, str ipAddress, bytes data)
 Sends a print string using TSPL or PGL to the specified IP address.
 

Static Public Member Functions

Tuple[str, int] parse_descriptor (str descriptor, DescriptorPortType port_type)
 
str descriptor_validate (str descriptor_hint, DescriptorPortType port_type_hint)
 Validates the descriptor with the specified hint and port type.
 
str descriptor_use_ip (str ip, int port)
 Returns a descriptor string using the specified IP and port.
 

Protected Attributes

 _socket
 
 _ip
 
 _port
 
 _connected
 

Constructor & Destructor Documentation

◆ __init__()

None TcpComm.TcpComm.__init__ ( self,
str ipAddress,
int port )

Initializes a new instance with the given IP address and port.

Parameters
ipAddressThe IP address of the TCP server.
portThe port number of the TCP server.

Member Function Documentation

◆ close()

None TcpComm.TcpComm.close ( self)

Closes the connection to the TCP server.

◆ connection_settings()

TcpComm.TcpComm.connection_settings ( self,
ip_address,
port )

Configures connection settings with the specified IP address and port.

Parameters
ip_addressThe IP address of the remote server.
portThe port number to connect to on the remote server.

◆ descriptor_use_ip()

str TcpComm.TcpComm.descriptor_use_ip ( str ip,
int port )
static

Returns a descriptor string using the specified IP and port.

Parameters
ipThe IP address to use in the descriptor.
portThe port to use in the descriptor.
Returns
A descriptor string.

◆ descriptor_validate()

str TcpComm.TcpComm.descriptor_validate ( str descriptor_hint,
DescriptorPortType port_type_hint )
static

Validates the descriptor with the specified hint and port type.

Parameters
descriptor_hintA hint for the descriptor.
port_type_hintThe type of port to validate.
Returns
A validated descriptor string.

◆ from_descriptor()

"TcpComm" TcpComm.TcpComm.from_descriptor ( cls,
str descriptor,
DescriptorPortType port_type )

Creates a TcpComm object from a descriptor string and port type.

Parameters
descriptorThe descriptor string representing the connection.
port_typeThe type of port to use for the connection.
Returns
An instance of the TcpComm class.

◆ get_ip_address()

str TcpComm.TcpComm.get_ip_address ( self)

Gets the IP address of the remote server.

Returns
The IP address of the remote server.

◆ is_connected()

bool TcpComm.TcpComm.is_connected ( self)

A flag indicating whether the connection is established.

Returns
True if the connection is open, False otherwise.

◆ open()

None TcpComm.TcpComm.open ( self)

Opens the connection to the TCP server.

◆ parse_descriptor()

Tuple[str, int] TcpComm.TcpComm.parse_descriptor ( str descriptor,
DescriptorPortType port_type )
static

◆ read()

Optional[bytes] TcpComm.TcpComm.read ( self)

Reads data from the TCP server.

Returns
The data read from the server.

◆ send_print_string()

None TcpComm.TcpComm.send_print_string ( self,
str ipAddress,
bytes data )

Sends a print string using TSPL or PGL to the specified IP address.

Parameters
ipAddressThe IP address of the printer.
dataThe data to print.

◆ send_printer_file()

None TcpComm.TcpComm.send_printer_file ( self,
str ipAddress,
str fileName )

Sends a print file to the specified IP address.

Parameters
ipAddressThe IP address of the printer.
fileNameThe name of the file to print.

◆ wait_for_data()

None TcpComm.TcpComm.wait_for_data ( self,
int msTimeout )

Waits for data to be available on the TCP connection.

Parameters
msTimeoutThe timeout interval in milliseconds.

◆ write()

None TcpComm.TcpComm.write ( self,
bytes text )

Writes data to the TCP server.

Parameters
textThe data to write to the server.

◆ write_and_wait_for_response()

Optional[bytes] TcpComm.TcpComm.write_and_wait_for_response ( self,
bytes text,
int responseStartTimeout,
int responseEndTimeout,
str completionToken = "" )

Writes data to the TCP server and waits for a response.

Parameters
textThe data to write to the server.
responseStartTimeoutThe timeout interval for the start of the response.
responseEndTimeoutThe timeout interval for the end of the response.
completionTokenA token indicating the completion of the response.
Returns
The data received in response from the server.

◆ write_and_wait_for_response_json()

Optional[bytes] TcpComm.TcpComm.write_and_wait_for_response_json ( self,
bytes text,
int responseStartTimeout,
int responseEndTimeout,
str completionToken = "" )

Writes JSON data to the TCP server and waits for a response.

Parameters
textThe JSON data to write to the server.
responseStartTimeoutThe timeout interval for the start of the response.
responseEndTimeoutThe timeout interval for the end of the response.
completionTokenA token indicating the completion of the response.
Returns
The data received in response from the server.

◆ write_printer_file()

TcpComm.TcpComm.write_printer_file ( self,
str fileName )

Writes a file to the printer.

Parameters
fileNameThe name of the file to write to the printer.

Member Data Documentation

◆ _connected

TcpComm.TcpComm._connected
protected

◆ _ip

TcpComm.TcpComm._ip
protected

◆ _port

TcpComm.TcpComm._port
protected

◆ _socket

TcpComm.TcpComm._socket
protected

The documentation for this class was generated from the following file: