arachnidlabs / mcp2210

Python library for interfacing with the MCP2210 USB-SPI interface.
BSD 2-Clause "Simplified" License
26 stars 18 forks source link

NameError: name 'buffer' is not defined #16

Open avijitnsec opened 6 years ago

avijitnsec commented 6 years ago

Got the following issue when working with Python 3.7 on Windows 10. Traceback (most recent call last): File "C:/Users/avijit.das/PycharmProjects/SampleTest/sample1.py", line 6, in dev = MCP2210(vid, pid) File "C:\Users\avijit.das\PycharmProjects\sample\venv\lib\site-packages\mcp2210\device.py", line 123, in init self.cancel_transfer() File "C:\Users\avijit.das\PycharmProjects\sample\venv\lib\site-packages\mcp2210\device.py", line 224, in cancel_transfer self.sendCommand(commands.CancelTransferCommand()) File "C:\Users\avijit.das\PycharmProjects\sample\venv\lib\site-packages\mcp2210\device.py", line 134, in sendCommand command_data = [ord(x) for x in buffer(command)] NameError: name 'buffer' is not defined

Process finished with exit code 1

avijitnsec commented 6 years ago

Source Code: from mcp2210 import MCP2210 vid=0x04d8 pid=0x00de dev = MCP2210(vid, pid) dev.transfer("data")

dev.manufacturer_name = "Foobar Industries Ltd" settings = dev.boot_chip_settings

print(settings)

tracernz commented 6 years ago

mcp2210 only supports Python 2. See http://python3porting.com/differences.html#buffer for the fix for this particular issue.