Changeset 3543
- Timestamp:
- 04/27/10 10:13:55 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykocard/trunk/pykocard/cartadistcrs.py
r3542 r3543 71 71 72 72 self.lastcommand = None 73 self.shortprompt = '$' 73 74 self.sol = chr(13) + chr(10) # start of line (begins each answer) 74 75 self.sollen = len(self.sol) 75 self.prompt = chr(13) + chr(10) + '$'# the prompt76 self.prompt = chr(13) + chr(10) + self.shortprompt # the prompt 76 77 self.promptlen = len(self.prompt) 77 78 self.eoc = chr(13) # end of command … … 99 100 self.tcrs.flushInput() 100 101 self.tcrs.flushOutput() 101 self.tcrs.read(1) # Skips the first $ prompt102 102 except serial.serialutil.SerialException, msg : 103 103 self.logError(msg) … … 152 152 answer = self.tcrs.readline(eol=self.prompt) 153 153 self.logDebug("TCRS answered %s" % repr(answer)) 154 if answer.startswith(self.shortprompt) : 155 answer = answer[len(self.shortprompt):] 154 156 if answer.startswith(command) : 155 157 answer = answer[len(command):] … … 157 159 return answer[self.sollen:-self.promptlen] 158 160 else : 159 if answer != self.sol:161 if answer and (answer != self.sol) : 160 162 self.logError("Unknown answer %s" % repr(answer)) 161 163 return None … … 282 284 if __name__ == "__main__" : 283 285 # Minimal testing 284 tcrs = CartadisTCRS("/dev/ttyS0", debug= False)286 tcrs = CartadisTCRS("/dev/ttyS0", debug=True) 285 287 try : 286 288 sys.stdout.write("%s TCRS detected on device %s with serial number %s\n" \