Add debug stuff for the MotorServer

This commit is contained in:
Piv
2019-09-29 10:29:09 +09:30
parent 34fc2f95f8
commit 17f3fceab9

View File

@@ -1,9 +1,11 @@
from threading import Timer, Thread
from gpiozero import Servo
from concurrent import futures
import grpc
from . import motorService_pb2
from . import motorService_pb2_grpc
from MotorControl.gpiozero.motor_session import Motor
servo_pin = 18
@@ -21,6 +23,7 @@ class MotorServicer(motorService_pb2_grpc.CarControlServicer):
# be sending values...
throttleFailed = False
for throttleRequest in request_iterator:
print('Setting throttle to: ' + throttleRequest.throttle)
self.set_timeout(timeout_length)
throttleFailed = self.motor.set_throttle(throttleRequest.throttle)
if throttleFailed:
@@ -48,3 +51,11 @@ class MotorServicer(motorService_pb2_grpc.CarControlServicer):
print("Node timeout elapsed")
self.motor.stop()
def start_server(self):
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
motorService_pb2_grpc.add_CarControlServicer_to_server(MotorServicer(), server)
server.add_insecure_port('[::]:50051')
server.start()
servicer = MotorServicer()
servicer.start_server()