diff --git a/MotorControl/MotorServer.py b/MotorControl/MotorServer.py index 85ea65f..72191a5 100644 --- a/MotorControl/MotorServer.py +++ b/MotorControl/MotorServer.py @@ -15,12 +15,17 @@ class MotorServicer(motorService_pb2_grpc.CarControlServicer): self.servo = Servo(servo_pin) self._timer = None - def SetThrottle(self, request, context): + def SetThrottle(self, request_iterator, context): # If we don't get a response every 3 seconds, stop the car. # This isn't a stream right now, however may change it to be so since we'll constantly # be sending values... - self.set_timeout(timeout_length) - return motorService_pb2.ThrottleResponse(throttleSet = (True if self.motor.set_throttle(request.throttle) else False)) + throttleFailed = False + for throttleRequest in request_iterator: + self.set_timeout(timeout_length) + throttleFailed = self.motor.set_throttle(throttleRequest.throttle) + if throttleFailed: + break + return motorService_pb2.ThrottleResponse(throttleSet = throttleFailed) def SetSteering(self, request, context): # TODO: Fix this to use the motor object as well to check for bounds.