AttributeError:attribute' port' ' liblo._ServerBase'对象不可写

时间:2017-06-17 09:31:30

标签: python-2.7

我是冥想头带和arduino。我想从缪斯获取数据并将它们交给arduino进行一些计算。

        #define libs
        from liblo import *
        import sys
        import time
        import serial
        import math

           #define arduino serial way
           ser = serial.Serial('/dev/ttyACM0')

           #class
           class MuseServer(ServerThread):

#listen for messages on port 5000
def __init__(self):
    ServerThread.__init__(self, port=5000)
    self.port=5000
    self.alpha = 0.0

  # take datas from device
  @make_method('/muse/acc', 'fff')
  def acc_callback(self, path, args):
  acc_x, acc_y, acc_z = args
  print "%s %f %f %f" % (path, acc_x, acc_y, acc_z)

       #connect to device
       try:
       server = MuseServer()
       except ServerError, err:
       print str(err)
       sys.exit()

       server.start()

       if __name__ == "__main__":
       while 1:
       time.sleep(1)

当我在终端上运行时,我会看到"属性错误:属性'端口' ' liblo._ServerBase'对象不可写"错误。

我使用Python 2.7

0 个答案:

没有答案