Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

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 »

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