libftdi Archives

Subject: Re: Problems with python example

From: Xiaofan Chen <xiaofanc@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Sat, 9 Jun 2018 20:40:02 +0800
On Sun, Jan 8, 2017 at 8:57 PM, Xiaofan Chen <xiaofanc@xxxxxxxxx> wrote:
> MyMacMini:python xiaofanc$ python complete.py
> version: 1.3
> devices: 1
> #0: manufacturer="FTDI" description="FT232R USB UART" serial="A8007Ub5"
> turning everything on
> Traceback (most recent call last):
>   File "complete.py", line 63, in <module>
>     ftdi.write_data(ftdic, chr(0xff), 1)
> TypeError: write_data() takes exactly 2 arguments (3 given)
>
> After removing the last argument, i.e., deleting " , 1", it seems to
> work fine. Maybe there is a change between libftdi1 version 1.2 and 1.3.

The issue is still in latest git.

(playusb) c:\work\libftdi\libftdi\python\examples>python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64
bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

1) simple.py works fine
(playusb) c:\work\libftdi\libftdi\python\examples>python simple.py
[FTDI version] major: 1, minor: 4, micro: 0, version_str: 1.4,
snapshot_str: v1.4-12-g91dbb65
ftdi.usb_open(): 0
ftdi.set_baudrate(): 0

2) cbus.py throws invalid syntax error
(playusb) c:\work\libftdi\libftdi\python\examples>python cbus.py
  File "cbus.py", line 93
    print 'manufacturer="%s" description="%s" serial="%s"' %
(manufacturer, description, serial)
                                                         ^
SyntaxError: invalid syntax

3) complete.py has the same problem as before.
(playusb) c:\work\libftdi\libftdi\python\examples>python complete.py
version: 1.4

devices: 1
#0: manufacturer="FTDI" description="FT232R USB UART" serial="A8007Ub5"

turning everything on
Traceback (most recent call last):
  File "complete.py", line 63, in <module>
    ftdi.write_data(ftdic, chr(0xff), 1)
TypeError: write_data() takes 2 positional arguments but 3 were given

4) After removing the last argument, i.e., deleting " , 1", it seems to
work a bit further but complete.py still does not work.

(playusb) c:\work\libftdi\libftdi\python\examples>python complete.py
version: 1.4

devices: 1
#0: manufacturer="FTDI" description="FT232R USB UART" serial="A8007Ub5"

turning everything on
TypeError: expected bytes, str found

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "complete.py", line 63, in <module>
    ftdi.write_data(ftdic, chr(0xff))
  File "C:\work\pyenv64\playusb\lib\site-packages\ftdi1.py", line 342,
in write_data
    return _ftdi1.write_data(ftdi, buf)
SystemError: <built-in function write_data> returned a result with an error set


-- 
Xiaofan

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread
  • Re: Problems with python example, Xiaofan Chen <=