dll_path = "ch347dlla64.dll"# Replace with the actual path to the DLL device_index = 0# Set the device index according to your requirements
ch347_driver = ch347.CH347Driver(dll_path)
result = ch347_driver.open_device(device_index) if result: print(f"Successfully opened device index: {device_index}") else: print(f"Failed to close device index: {device_index}")
result, driver_ver, dll_ver, device_ver, chip_type = ch347_driver.get_version(device_index) if result: print("Version Information:") print(f"Driver Version: {driver_ver}") print(f"DLL Version: {dll_ver}") print(f"Device Version: {device_ver}") print(f"Chip Type: {chip_type}") else: print("Failed to get version information.")
result = ch347_driver.i2c_set(device_index, 1) if result: print("Success to set I2C speed.") else: print("Failed to set I2C speed.")
result = ch347_driver.i2c_set_delay_ms(device_index, 1) if result: print("Success to set I2C delay.") else: print("Failed to set I2C delay.")
result = ch347_driver.stream_i2c(device_index, b'\xd0\x75', 1) if result: print("Success! result:", result.hex()) else: print("Failed!")
# Example usage of CH347CloseDevice result = ch347_driver.close_device(device_index) if result: print(f"Successfully closed device index: {device_index}") else: print(f"Failed to close device index: {device_index}")