<div class="gmail_quote">On Mon, Jan 23, 2012 at 4:48 PM, M.Pekala <span dir="ltr"><<a href="mailto:mcdpekala@gmail.com">mcdpekala@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello, I am having some trouble with a serial stream on a project I am<br>
When one sensor is running my python script grabs the data just fine,<br>
removes the formatting, and throws it into a text control box. However<br>
when 3 or more sensors are running, I get output like the following:<br>
<br>
Sensor 1: 373<br>
Sensor 2: 112$$M-160$G373<br>
Sensor 3: 763$$A892$<br>
<br>
I am fairly certain this means that my code is running too slow to<br>
catch all the '$' markers. Below is the snippet of code I believe is<br>
the cause of this problem...<br></blockquote><div><br>That doesn't sound right. Being too slow seems unlikely to produce the wrong data... <br></div><div><br><br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
def OnSerialRead(self, event):<br>
text = event.data<br>
self.sensorabuffer = self.sensorabuffer + text<br>
self.sensorbbuffer = self.sensorbbuffer + text<br>
self.sensorcbuffer = self.sensorcbuffer + text<br>
<br>
if sensoraenable:<br>
sensorresult = re.search(r'\$A.*\$.*', self.sensorabuffer )<br></blockquote><div><br>Here, you search in sensorabuffer (which, by the way, would be much more readable to me as sensor_a_buffer, as recommended by the PEP 8 style guide).<br>
<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> if sensorbenable:<br>
sensorresult = re.search(r'\$A.*\$.*', self.sensorbenable)<br></blockquote><div><br>here, you're not searching in the buffer, but in the enable flag.<br><br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
if sensorcenable:<br>
sensorresult = re.search(r'\$A.*\$.*', self.sensorcenable)<br></blockquote></div><br>And here too.<br><br>Does that fix the problem?<br><br>-- <br>Jerry<br>