我在写一个程序,用串行对象和一个Arduino装置通信。在类的init-方法中可以找到这段代码:
try:
self.rotor = serial.Serial(port = "COM22", baudrate=115200, timeout = 0.1, writeTimeout = 1)
except serial.SerialException, e:
print "Error when connecting to collimator: ", e
当我运行它时,我得到以下错误消息:
^{pr2}$我要求计算机打开COM22,它回答说不能打开COM1。什么 关于什么?Arduino装置插入COM22。在
我有另一个程序,我还没有自己编写,但它使用同一个类库。这个程序能用,但我不明白怎么用。是否有一些串行对象的初始化我没有做?在
从PySerial SVN trunk(http://svn.code.sf.net/p/pyserial/code/trunk/pyserial/serial/serialwin32.py)中
Win32Serial
对象的源代码:所以把你的代码改成:
^{pr2}$应该能正常工作。在
我后来发现错误源于错误定义的模块路径 用类定义。路径被定向到旧版本的 相同的文件。在
相关问题 更多 >
编程相关推荐