Python Forum

Full Version: AttributeError: attribute 'port' of 'liblo._ServerBase' objects is not writable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i ve muse headband and arduino.I want to take datas from muse and give them to arduino for some calculations.

#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)
When i run on terminal i see "AttributeError: attribute 'port' of 'liblo._ServerBase' objects is not writable" Error.

I use Python 2.7
repost your code with proper indentation and in code tags. see BBcode help for more info
i ve muse headband and arduino.I want to take datas from muse and give them to arduino for some calculations.
#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)
When i run on terminal i see :
Error:
AttributeError: attribute 'port' of 'liblo._ServerBase' objects is not writable" Error.
I use Python 2.7

First of all i want to state my apologies.I am new to Python and Forum.
I frequently violate forum rules.I ll be more careful after that.
Is there an easy way to fix this indentation?
What kind of Python editor should i use?
Or what is suggestions?
Thanks.