doxygenAutoDocs
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Attributes | List of all members
CommSDK.CommSDK Class Reference

Public Member Functions

 __init__ (self)
 
int GetBytesAvailable (self)
 
bool Connected (self)
 
 Read (self, buffer, size)
 
 Write (self, data_out, data_size)
 
 WriteAndWaitForResponse (self, data_out, data_size, response_start_time_out, response_end_time_out, completion_token)
 
 Close (self)
 
 StopAsyncListening (self)
 
 Open (self)
 
 SendPrintFile (self, ipAddress, fileName)
 
 SendPrintString (self, ipAddress, data, iDataSize)
 
Tuple[List[Tuple_c], int] GetAvailableDevices (self)
 
 UsbConnection (self, Tuple_c device)
 
 TcpConnection (self, str ipAddress, int port)
 
 BtConnection (self, str macAddress)
 
Union[CObject, None] GetComm (self)
 

Public Attributes

 giComm
 

Protected Attributes

 _socket
 

Constructor & Destructor Documentation

◆ __init__()

CommSDK.CommSDK.__init__ ( self)

Member Function Documentation

◆ BtConnection()

CommSDK.CommSDK.BtConnection ( self,
str macAddress )
Connect to the selected bluetooth device

Param: 
mac_address: MAC address for bluetooth device

Return: None

Sample:

BtConnection("34:81:F4:43:3D:A8")

◆ Close()

CommSDK.CommSDK.Close ( self)
Disconnect the printer

Return: None

Sample:

Close()

◆ Connected()

bool CommSDK.CommSDK.Connected ( self)
Is connected with the selected I/F (USB/NET/BT)

Return: 
    - True if connected
    - False otherwise

Sample:

if Connected():
    print("Connected")

◆ GetAvailableDevices()

Tuple[List[Tuple_c], int] CommSDK.CommSDK.GetAvailableDevices ( self)
Return the v_id and p_id of valid devices in the format of Tuple_c {short v_id; short p_id;}. The "v_id" refers to the Vendor ID, and "p_id" refers to the Vendor ID.

Param: 
devices: Tuple_c to store v_id & p_id
count: The count of USB device(s)

Return: int

Sample:

devices = None
count = 0
GetAvailableDevices(devices, count)

◆ GetBytesAvailable()

int CommSDK.CommSDK.GetBytesAvailable ( self)
Get the bytes available

Return:
    - 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

Param: 
ptr_comm: A pointer to storage communicating I/F

Return: None

Sample:

commPtr = None
GetComm(commPtr)

◆ Open()

CommSDK.CommSDK.Open ( self)
Open the printer through the selected I/F (USB/NET/BT)

Return: None

Sample:

Open()

◆ Read()

CommSDK.CommSDK.Read ( self,
buffer,
size )
Read data through the selected I/F (USB/NET/BT) from printer

Param: 
buffer: The buffer to store data
size: The size of the buffer

Return: 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 I/F

Param: 
ip_address: IP address
file_name: File path

Return: None

Sample:

SendPrintFile("10.0.10.172", "rfid.pgl")

◆ SendPrintString()

CommSDK.CommSDK.SendPrintString ( self,
ipAddress,
data,
iDataSize )
Send the string through the NET I/F

Param: 
ip_address: IP address
data: The data to send to the printer
data_size: The size of the data

Return: 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

Param: 
ip_address: IP address
port: Port number (e.g., 9100)

Return: None

Sample:

TcpConnection("10.100.15.214", 9100)

◆ UsbConnection()

CommSDK.CommSDK.UsbConnection ( self,
Tuple_c device )
Connect to the selected USB device

Param: 
devices: Tuple_c for v_id & p_id of selected USB device

Return: None

Sample:

UsbConnection(usb_tuple)

◆ Write()

CommSDK.CommSDK.Write ( self,
data_out,
data_size )
Write data through the selected I/F (USB/NET/BT) to printer

Param: 
data_out: The data to write to printer
data_size: The size of the data to write to printer

Return: 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.

Param: 
data_out: The data to write to printer
data_size: The size of the data to write to printer
response_start_timeout: Timeout to wait for first data to be received. Time to first byte
response_end_timeout: Timeout of no new data received. Time after last byte
completion_token: String 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.

Return: 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

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