From ad417a46738258c2d626ae4eca69e3b1d34f93ea Mon Sep 17 00:00:00 2001 From: nonNoise Date: Thu, 15 Aug 2019 14:56:07 +0900 Subject: [PATCH] VID,PID BugFix. --- PyMCP2221A/PyMCP2221A.py | 4 ++-- PyMCP2221A/SMBus.py | 4 +++- example/PyMCP2221A/PyMCP2221A.py | 4 ++-- example/PyMCP2221A/SMBus.py | 4 +++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/PyMCP2221A/PyMCP2221A.py b/PyMCP2221A/PyMCP2221A.py index 16a47ab..e2e2c6c 100644 --- a/PyMCP2221A/PyMCP2221A.py +++ b/PyMCP2221A/PyMCP2221A.py @@ -3,7 +3,7 @@ # Copyright (c) 2017 Yuta KItagami # ############################################################# -from hidapi import hid +import hid #import hid # pip install hidapi # https://github.com/trezor/cython-hidapi @@ -13,7 +13,7 @@ class PyMCP2221A: def __init__(self,VID = 0x04D8,PID = 0x00DD,devnum = 0): self.mcp2221a = hid.device() - self.mcp2221a.open_path(hid.enumerate(0x04D8, 0x00DD)[devnum]["path"]) + self.mcp2221a.open_path(hid.enumerate(VID, PID)[devnum]["path"]) self.CLKDUTY_0 = 0x00 self.CLKDUTY_25 = 0x08 self.CLKDUTY_50 = 0x10 diff --git a/PyMCP2221A/SMBus.py b/PyMCP2221A/SMBus.py index 3649ade..3d9afb6 100644 --- a/PyMCP2221A/SMBus.py +++ b/PyMCP2221A/SMBus.py @@ -32,4 +32,6 @@ def read_i2c_block_data(self, addrs,cmd,size): return self.mcp2221.I2C_Read_Repeated(addrs,size) def write_i2c_block_data(self, addrs,cmd,vals): self.mcp2221.I2C_Write(addrs,[cmd,vals]) - + def reset(self): + self.mcp2221.Reset() + \ No newline at end of file diff --git a/example/PyMCP2221A/PyMCP2221A.py b/example/PyMCP2221A/PyMCP2221A.py index 16a47ab..e2e2c6c 100644 --- a/example/PyMCP2221A/PyMCP2221A.py +++ b/example/PyMCP2221A/PyMCP2221A.py @@ -3,7 +3,7 @@ # Copyright (c) 2017 Yuta KItagami # ############################################################# -from hidapi import hid +import hid #import hid # pip install hidapi # https://github.com/trezor/cython-hidapi @@ -13,7 +13,7 @@ class PyMCP2221A: def __init__(self,VID = 0x04D8,PID = 0x00DD,devnum = 0): self.mcp2221a = hid.device() - self.mcp2221a.open_path(hid.enumerate(0x04D8, 0x00DD)[devnum]["path"]) + self.mcp2221a.open_path(hid.enumerate(VID, PID)[devnum]["path"]) self.CLKDUTY_0 = 0x00 self.CLKDUTY_25 = 0x08 self.CLKDUTY_50 = 0x10 diff --git a/example/PyMCP2221A/SMBus.py b/example/PyMCP2221A/SMBus.py index 3649ade..3d9afb6 100644 --- a/example/PyMCP2221A/SMBus.py +++ b/example/PyMCP2221A/SMBus.py @@ -32,4 +32,6 @@ def read_i2c_block_data(self, addrs,cmd,size): return self.mcp2221.I2C_Read_Repeated(addrs,size) def write_i2c_block_data(self, addrs,cmd,vals): self.mcp2221.I2C_Write(addrs,[cmd,vals]) - + def reset(self): + self.mcp2221.Reset() + \ No newline at end of file