Jump to content
freesumo

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

Recommended Posts

deathseeker25

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
h.setTimeouts(1000,1000)

# 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

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.