UniPRT SDK v1.0.0.0-so (Python)
 
Loading...
Searching...
No Matches
CommSDK.CommSDK Class Reference

Public Member Functions

 __init__ (self)
 
int GetBytesAvailable (self)
 Get the bytes available.
 
bool Connected (self)
 Is connected with the NET.
 
 Read (self, buffer, size)
 Read data through the NET from printer.
 
 Write (self, data_out, data_size)
 Write data through the NET to printer.
 
 WriteAndWaitForResponse (self, data_out, data_size, response_start_time_out, response_end_time_out, completion_token)
 Write byte data to output stream and return data received.
 
 Close (self)
 Disconnect the printer.
 
 StopAsyncListening (self)
 
 Open (self)
 Open the printer through the NET.
 
 SendPrintFile (self, ipAddress, fileName)
 Send file through the NET.
 
 SendPrintString (self, ipAddress, data, iDataSize)
 Send the string through the NET.
 
 TcpConnection (self, str ipAddress, int port)
 Connect to the selected NET device.
 
Union[CObject, None] GetComm (self)
 Get the pointer of communicating I/F.
 

Public Attributes

 giComm
 

Protected Attributes

 _socket
 

Constructor & Destructor Documentation

◆ __init__()

CommSDK.CommSDK.__init__ ( self)

Member Function Documentation

◆ Close()

CommSDK.CommSDK.Close ( self)

Disconnect the printer.

Returns
None
Sample
Close()

◆ Connected()

bool CommSDK.CommSDK.Connected ( self)

Is connected with the NET.

Returns
  • True if connected
  • False otherwise
Sample
if Connected():
print("Connected")

◆ GetBytesAvailable()

int CommSDK.CommSDK.GetBytesAvailable ( self)

Get the bytes available.

Returns
  • Greater than 0 : The size of data bytes available
  • Equal to 0 : None
Sample
iBytes = GetBytesAvailable()

◆ GetComm()

Union[CObject, None] CommSDK.CommSDK.GetComm ( self)

Get the pointer of communicating I/F.

Returns
None
Sample
commPtr = None
GetComm(commPtr)

◆ Open()

CommSDK.CommSDK.Open ( self)

Open the printer through the NET.

Returns
None
Sample
Open()

◆ Read()

CommSDK.CommSDK.Read ( self,
buffer,
size )

Read data through the NET from printer.

Parameters
[in]bufferThe buffer to store data
[in]sizeThe size of the buffer
Returns
None
Sample
i_bytes = GetBytesAvailable()
p_buf = bytearray(i_bytes)
Read(p_buf, i_bytes)

◆ SendPrintFile()

CommSDK.CommSDK.SendPrintFile ( self,
ipAddress,
fileName )

Send file through the NET.

Parameters
[in]ipAddressIP address
[in]fileNameFile path
Returns
None
Sample
SendPrintFile("10.0.10.172", "rfid.pgl")

◆ SendPrintString()

CommSDK.CommSDK.SendPrintString ( self,
ipAddress,
data,
iDataSize )

Send the string through the NET.

Parameters
[in]ipAddressIP address
[in]dataThe data to send to the printer
[in]iDataSizeThe size of the data
Returns
None
Sample
SendPrintString("10.0.10.172", "FEED 100", len("FEED 100"))

◆ StopAsyncListening()

CommSDK.CommSDK.StopAsyncListening ( self)

◆ TcpConnection()

CommSDK.CommSDK.TcpConnection ( self,
str ipAddress,
int port )

Connect to the selected NET device.

Parameters
[in]ipAddressIP address
[in]portPort number (e.g., 9100)
Returns
None
Sample
TcpConnection("10.100.15.214", 9100)

◆ Write()

CommSDK.CommSDK.Write ( self,
data_out,
data_size )

Write data through the NET to printer.

Parameters
[in]data_outThe data to write to printer
[in]data_sizeThe size of the data to write to printer
Returns
None
Sample
content = "FEED 100"
p_str = content.encode('utf-8')
Write(p_str, len(p_str))

◆ WriteAndWaitForResponse()

CommSDK.CommSDK.WriteAndWaitForResponse ( self,
data_out,
data_size,
response_start_time_out,
response_end_time_out,
completion_token )

Write byte data to output stream and return data received.

Data returned is any data received or up to completion token if received. Wait for response timeout before returning.

Parameters
[in]data_outThe data to write to printer
[in]data_sizeThe size of the data to write to printer
[in]response_start_time_outTimeout to wait for first data to be received. Time to first byte
[in]response_end_time_outTimeout of no new data received. Time after last byte
[in]completion_tokenString token denoting the end of the response expected. This can be an empty string if simply want to wait for response after writing data to connection.
Returns
A bytes object received from the connection. Data returned is any data received or up to completion_token if token received
Sample
content = "FEED 100\r\nOUT \"12345678\"\r\n"
print("Send to Printer:")
print(content)
p_response = WriteAndWaitForResponse(content.encode('utf-8'), len(content), 1000, 500, "\r\n")

Member Data Documentation

◆ _socket

CommSDK.CommSDK._socket
protected

◆ giComm

CommSDK.CommSDK.giComm