UniPRT SDK v2.0.0.0
 
载入中...
搜索中...
未找到
UsbComm.UsbComm类 参考

Public 成员函数

 __init__ (self, vendor_id, product_id)
 初始化 UsbComm 类的新实例。
 
 descriptor_use_vendor_id (self, vId, pId)
 
 open (self)
 打开到 USB 设备的连接。
 
bool is_connected (self)
 检查 USB 设备是否已连接。
 
 async_listen_read (self)
 异步监听并读取来自 USB 设备的数据。
 
 stop_listen_read (self)
 停止监听并读取来自 USB 设备的数据。
 
 close (self)
 关闭 USB 设备的连接。
 
 write (self, text)
 将数据写入 USB 设备。
 
 read (self)
 从 USB 设备读取数据。
 
 write_and_wait_for_response (self, text, response_start_timeout, response_end_timeout, completion_token="")
 向设备写入数据并等待响应。
 
 write_and_wait_for_response_json (self, text, response_start_timeout, response_end_timeout, completion_token="")
 向设备写入数据并等待响应。
 

Public 属性

 data_to_write = None
 
int total_batches = 0
 
int current_batch = 0
 
 run_loop_thread = threading.Thread(target=self.run_loop_thread_entry)
 

Protected 属性

bool _connected = False
 
 _vId = int(vendor_id)
 
 _pId = int(product_id)
 
 _matched_interfaces = None
 
list _discovered_interfaces = []
 
bool _should_stop_read_loop = True
 
dict _device_list = {}
 

构造及析构函数说明

◆ __init__()

UsbComm.UsbComm.__init__ ( self,
vendor_id,
product_id )

初始化 UsbComm 类的新实例。

参数
vendor_id实例的供应商 ID。
product_id实例的产品 ID。

成员函数说明

◆ async_listen_read()

UsbComm.UsbComm.async_listen_read ( self)

异步监听并读取来自 USB 设备的数据。

◆ close()

UsbComm.UsbComm.close ( self)

关闭 USB 设备的连接。

◆ descriptor_use_vendor_id()

UsbComm.UsbComm.descriptor_use_vendor_id ( self,
vId,
pId )

◆ is_connected()

bool UsbComm.UsbComm.is_connected ( self)

检查 USB 设备是否已连接。

返回
: 如果已连接返回 True,否则返回 False。

◆ open()

UsbComm.UsbComm.open ( self)

打开到 USB 设备的连接。

◆ read()

UsbComm.UsbComm.read ( self)

从 USB 设备读取数据。

返回
: 从设备读取的数据。

◆ stop_listen_read()

UsbComm.UsbComm.stop_listen_read ( self)

停止监听并读取来自 USB 设备的数据。

◆ write()

UsbComm.UsbComm.write ( self,
text )

将数据写入 USB 设备。

参数
text要写入设备的数据。

◆ write_and_wait_for_response()

UsbComm.UsbComm.write_and_wait_for_response ( self,
text,
response_start_timeout,
response_end_timeout,
completion_token = "" )

向设备写入数据并等待响应。

参数
text要写入设备的数据。
response_start_timeout响应开始的超时间隔。
response_end_timeout响应结束的超时间隔。
completion_token指示响应完成的令牌。
返回
: 从设备收到的响应数据。

◆ write_and_wait_for_response_json()

UsbComm.UsbComm.write_and_wait_for_response_json ( self,
text,
response_start_timeout,
response_end_timeout,
completion_token = "" )

向设备写入数据并等待响应。

参数
text要写入设备的数据。
response_start_timeout响应开始的超时间隔。
response_end_timeout响应结束的超时间隔。
completion_token指示响应完成的令牌。
返回
: 从设备收到的响应数据。

类成员变量说明

◆ _connected

bool UsbComm.UsbComm._connected = False
protected

◆ _device_list

dict UsbComm.UsbComm._device_list = {}
protected

◆ _discovered_interfaces

list UsbComm.UsbComm._discovered_interfaces = []
protected

◆ _matched_interfaces

UsbComm.UsbComm._matched_interfaces = None
protected

◆ _pId

UsbComm.UsbComm._pId = int(product_id)
protected

◆ _should_stop_read_loop

bool UsbComm.UsbComm._should_stop_read_loop = True
protected

◆ _vId

UsbComm.UsbComm._vId = int(vendor_id)
protected

◆ current_batch

int UsbComm.UsbComm.current_batch = 0

◆ data_to_write

UsbComm.UsbComm.data_to_write = None

◆ run_loop_thread

UsbComm.UsbComm.run_loop_thread = threading.Thread(target=self.run_loop_thread_entry)

◆ total_batches

int UsbComm.UsbComm.total_batches = 0

该类的文档由以下文件生成: