Another newbee question about Serial.Read

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
P.K.Tonkes
Posts: 1
Joined: Sun Feb 22, 2009 8:43 pm
Location: Netherlands
Contact:

Another newbee question about Serial.Read

Post by P.K.Tonkes » Mon Dec 27, 2010 12:13 pm

I thought it was simpel but i'm getting frustrated now...

I want to read an analog value from a domotica controller called 'Nodo'. After sending 'Status WiredAnalog 1;' to the serial port, the domotica controller immidiately responds with 'WiredAnalog 1, 31)' terminated with 0x10. I want to catch this string so I can extract the value 31, but my Python script does not catch the string properly.

This is (a part of) my pyton script:

Code: Select all

Serial = eg.plugins.Serial

print 'Get the analog value...'

Serial.Write(u'Status WiredAnalog 1;')

ReceivedString = ""
b=0

# receive all input until \n
while b != "\n":
    b=Serial.Read(1, 0.1)
    if b != "":
        ReceivedString += b
    
print "Return value: " + ReceivedString
My scripts only returns only parts of the returned serial string of hash. I'm sure the serial connection is Ok.

Can anybody help?

Post Reply