I am writing the code used to send an order to avr. I send some data, but between each record I have to wait for an answer (I need to wait until the robot reaches a point in the coordinate system). As I read in the documentation, readline() should at least read before the timeout, but as soon as I send the first coordinate, readline () will automatically return:
SerialException: device reports readiness to read but returned no data (device disconnected?)
When I put a sleep() between each write() in a for loop, everything works fine. I tried to use inWaiting() , but it still does not work. Here is an example of how I used it:
for i in chemin_python: self.serieInstance.ecrire("goto\n" + str(float(ix)) + '\n' + str(float(-iy)) + '\n') while self.serieInstance.inWaiting(): pass lu = self.serieInstance.readline() lu = lu.split("\r\n")[0] reponse = self.serieInstance.file_attente.get(lu) if reponse != "FIN_GOTO": log.logger.debug("Erreur asservissement (goto) : " + reponse)
source share