• Revista PROGRAMAR: Já está disponível a edição #53 da revista programar. Faz já o download aqui!


Jython / Python/FTDI-USB module / Python for Windows Extensions

2 posts in this topic

Jython is an implementation of the high-level, dynamic, object-oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform.

Python integrado com Java?! Wow....isto deve ser potente. Tenho realmente que voltar a bater código em Python. O PyUSB tambem é interessante, na medida em que permite programar a porta USB e chips ligados, assim como conversores USB.

# ----------
# import the PyUSB module
import d2xx

# list devices by description, returns tuple of attached devices description strings
d = d2xx.listDevices(d2xx.OPEN_BY_DESCRIPTION)
print d

# list devices by serial, returns tuple of attached devices serial strings
d = d2xx.listDevices() # implicit d2xx.OPEN_BY_SERIAL_NUMBER
print d

h = d2xx.open(0)
print h

# read eeprom
print h.eeRead()

# get queue status
print h.getQueueStatus()

# set RX/TX timeouts

# write bytes (serial mode)
print h.write('Hello world!\r\n")

# read bytes (serial mode)
print h.read(5)

# ----------

Python é fantástico....aproveitem.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now