We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Generally, is there library documentation for the libraries with Processing.py?
Specifically, I'm trying to use the Serial library. Guessing the syntax from the Java documentation, I have:
add_library('serial')
def setup():
#setup the serial port
print Serial.list()
portIndex = 4
LF = 10
print "Connecting to ", Serial.list()[portIndex]
myPort = Serial(Serial.list()[portIndex], 9600) # this seems to need a first argument referring to the sketch object (analagous to "this" argument in Java)
myPort.bufferUntil(LF)
def draw():
pass
def serialEvent(evt):
inString = evt.readString()
print inString
Anyone have any advice on making this work?
As a side note, it would be nice to add a processing.py as a subcategory in the forums under "Questions and Modes".
Answers
http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text
You just need to add
this
to the argument list, as in:Although this gets you past the your first error, I am encountering the following error:
once it runs. Running the example 'SimpleRead' opens the serial port just fine. I wish I knew what I was doing wrong.
Thanks, I added "this" to the arguments list.
I also get the same error and its a great mystery to me too.
This was a bug under OSX and has jut been fixed: https://github.com/jdf/Processing.py-Bugs/issues/124
Open processing, go to the modes dropdown, click install new mode, then remove Python. Quit, restart, reload Python mode. Quit, restart, and you're good to go with the fix.
Just for the record... Firmata is working great on Processing Python Mode, you can find an example here: https://github.com/jdf/processing.py/tree/master/mode/examples/Contributed Libraries in Python/Arduino-Firmata