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 = {} |
| UsbComm.UsbComm.__init__ | ( | self, | |
| vendor_id, | |||
| product_id ) |
初始化 UsbComm 类的新实例。
| vendor_id | 实例的供应商 ID。 |
| product_id | 实例的产品 ID。 |
| UsbComm.UsbComm.async_listen_read | ( | self | ) |
异步监听并读取来自 USB 设备的数据。
| UsbComm.UsbComm.close | ( | self | ) |
关闭 USB 设备的连接。
| UsbComm.UsbComm.descriptor_use_vendor_id | ( | self, | |
| vId, | |||
| pId ) |
| bool UsbComm.UsbComm.is_connected | ( | self | ) |
检查 USB 设备是否已连接。
| UsbComm.UsbComm.open | ( | self | ) |
打开到 USB 设备的连接。
| UsbComm.UsbComm.read | ( | self | ) |
从 USB 设备读取数据。
| UsbComm.UsbComm.stop_listen_read | ( | self | ) |
停止监听并读取来自 USB 设备的数据。
| UsbComm.UsbComm.write | ( | self, | |
| text ) |
将数据写入 USB 设备。
| text | 要写入设备的数据。 |
| 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 | 指示响应完成的令牌。 |
| 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 | 指示响应完成的令牌。 |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
| int UsbComm.UsbComm.current_batch = 0 |
| UsbComm.UsbComm.data_to_write = None |
| UsbComm.UsbComm.run_loop_thread = threading.Thread(target=self.run_loop_thread_entry) |
| int UsbComm.UsbComm.total_batches = 0 |