def read2(self, how_much=<NUM_LIT>):  
ret = []<EOL>self.setRTS(self.DD_READ)<EOL>header = [<NUM_LIT>, <NUM_LIT>, <NUM_LIT>]<EOL>ptr = <NUM_LIT:0><EOL>while True:<EOL><INDENT>b = self.serial.read(<NUM_LIT:1>)<EOL>if not b:<EOL><INDENT>return None<EOL><DEDENT>b = ord(b)<EOL>print('<STR_LIT:b>', b)<EOL>if b == header[ptr]:<EOL><INDENT>ptr += <NUM_LIT:1><EOL>ret.append(b)<EOL>if ptr == <NUM_LIT:3>:  <EOL><INDENT>print('<STR_LIT>')<EOL>d = self.serial.read(<NUM_LIT:1>)  <EOL>ret.append(ord(d))<EOL>l, h = self.serial.read(<NUM_LIT:2>)  <EOL>l = ord(l)<EOL>h = ord(h)<EOL>ret.append(l)<EOL>ret.append(h)<EOL>length = (h << <NUM_LIT:8>) + l<EOL>print('<STR_LIT>', length)<EOL>how_many = length<EOL>while how_many > <NUM_LIT:0>:<EOL><INDENT>print('<STR_LIT>', how_many)<EOL>d = self.serial.read(how_many)<EOL>d = self.decode(d)<EOL>print('<STR_LIT>', len(d))<EOL>how_many -= len(d)<EOL>for i in d:<EOL><INDENT>ret.append(i)<EOL><DEDENT><DEDENT>print('<STR_LIT>')<EOL>return [ret]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>ret = []<EOL>ptr = <NUM_LIT:0><EOL><DEDENT><DEDENT>return ret<EOL>
This toggles the RTS pin and reads in data. It also converts the buffer
back into a list of bytes and searches through the list to find valid
packets of info. If there is more than one packet, this returns an
array of valid packets.