Re: [Tutor] PYFTDI Library for FT232H

2012-08-02 Thread Steven D'Aprano

On 03/08/12 09:38, John Battle wrote:

I am relatively new to Pyton and am trying to use a library called pyftdi
which is used to establish communication with USB chips made by FTDI. I have
been able to install the library and write a simple piece of code to discover
my interfaces (I have two FT232H devices connected). The following code seems
to work to accomplish that:

#!/usr/bin/python
from pyftdi.pyftdi.ftdi import *
vps=[(0x0403,0x6014)]
devs=Ftdi.find_all(vps)
print devs

However I cannot figure out what to do next.



If you are talking about this library:

http://pypi.python.org/pypi/pyftdi

have you tried reading the documentation, such as it is? I've had a quick 
look, and it appears to be extremely light on documentation, but I didn't dig 
too deeply, maybe you will have better luck. The GitHub page claims to have 
some examples, but I couldn't get it to work in my browser.


You can also try this at the Python interactive interpreter:

import pyftdi
help(pyftdi)


and see if the library has any useful embedded documentation. It may not.


Do you know how to start the interactive interpreter? You need to open a 
terminal window, then at the prompt, you need to launch Python. Under Linux, I 
just type


python

and hit the ENTER key. If you are using Windows, it may be more complicated.



--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] PYFTDI Library for FT232H

2012-08-02 Thread Alan Gauld

On 03/08/12 00:38, John Battle wrote:

I am relatively new to Pyton and am trying to use a library called
pyftdi which is used to establish communication with USB chips


This list is really for those learning the core Python language and 
standard library. Although we do cover some common third party libraries 
too it's not really our purpose.


You might be very lucky and find someone who knows this particular 
library but you will generally have better success on a support forum 
for the library or by writing the author directly. Failing that you 
could try the main Python mailing list/newsgroup.



I have a C program that will do this but I need to do it in Python.


If it's simply how to translate the C to Python we might be able to 
help. If you can post a short example of the C that you want to

emulate we may be able to help with that.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] PYFTDI Library for FT232H

2012-08-02 Thread John Battle
I am relatively new to Pyton and am trying to use a library called 
pyftdi which is used to establish communication with USB chips made by 
FTDI.  I have been able to install the library and write a simple piece 
of code to discover my interfaces (I have two FT232H devices 
connected).  The following code seems to work to accomplish that:


#!/usr/bin/python
from pyftdi.pyftdi.ftdi import *
vps=[(0x0403,0x6014)]
devs=Ftdi.find_all(vps)
print devs

However I cannot figure out what to do next.  The devices in question 
are programmed n the FT245 Syncronous mode and I need to send a short 
string to one of them to start a data download and then receive straming 
data on the other one.


I have a C program that will do this but I need to do it in Python.

Any help would be gretly appreciated.

Thanks

John Battle



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] __new__ and __init__

2012-08-02 Thread Alan Gauld

On 01/08/12 15:28, rail shafigulin wrote:


I'm trying to understand how to use the two methods. I know that __new__
is used to create an object, while __init__ to initialize. But I'm not
sure what happens when I create an object.


Use print statements to find out...

>>> class C(object):
...def __new__(cls):
...print 'in new'
...return object.__new__(cls)
...def __init__(slf): print 'in init'
...
>>> c = C()
in new
in init
>>>



1) Does it mean that __new__ and __init__ must have the same parameters?
In this particular case __new__ and __init__ both have model_name and if
I understand correctly when __new__ is called the rest of the parameters
(air, tilt, cruise_control, etc) are absorbed by the *args argument.


That's right and I've never tried doing it differently
 - but again the >>> prompt and print are your friends


2) What happens if I don't use the same parameters, say in the case of
__init__ I will remove model_name, will I still be able to call dx =
CarModel("Fix DX")



The best way to be sure is to try it. That's the joy of an interactive 
prompt... you never need to guess.



--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor