Page 1 of 1

Another newbee question about Serial.Read

Posted: Mon Dec 27, 2010 12:13 pm
by P.K.Tonkes
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?