公開方法(Public Methods) | |
| __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="") | |
| 向設備寫入數據並等待回應。 | |
公開屬性 | |
| data_to_write = None | |
| int | total_batches = 0 |
| int | current_batch = 0 |
| run_loop_thread = threading.Thread(target=self.run_loop_thread_entry) | |
保護屬性 | |
| 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 |