Processing.py的串口库有文档吗?
我已经从Java Serial库文档中猜测了一些语法。这是我目前所拥有的:
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)
myPort.bufferUntil(LF)
def draw():
pass
def serialEvent(evt):
inString = evt.readString()
print inString
我遇到了以下错误:
processing.app.SketchException: TypeError: processing.serial.Serial(): 1st arg can't be coerced to processing.core.PApplet
Java语言中创建Serial实例的语法将"this"作为第一个参数,我认为它指的是Sketch(PApplet)对象。在processing.py中,我该如何引用它?
this
作为函数参数。如果我将this
添加为串行连接行的第一个参数,我会得到一个新的错误:processing.app.SketchException: java.lang.UnsatisfiedLinkError: jssc.SerialNativeInterface.openPort(Ljava/lang/String;Z)J
。 - ericksonlathis
关键字是为了与Processing Java库兼容而使用的,它几乎在每个库中都被使用 :) - villares