Add debug stuff for the MotorServer
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
from threading import Timer, Thread
|
from threading import Timer, Thread
|
||||||
from gpiozero import Servo
|
from gpiozero import Servo
|
||||||
|
from concurrent import futures
|
||||||
|
|
||||||
|
import grpc
|
||||||
|
|
||||||
from . import motorService_pb2
|
from . import motorService_pb2
|
||||||
from . import motorService_pb2_grpc
|
from . import motorService_pb2_grpc
|
||||||
|
|
||||||
from MotorControl.gpiozero.motor_session import Motor
|
from MotorControl.gpiozero.motor_session import Motor
|
||||||
|
|
||||||
servo_pin = 18
|
servo_pin = 18
|
||||||
@@ -21,6 +23,7 @@ class MotorServicer(motorService_pb2_grpc.CarControlServicer):
|
|||||||
# be sending values...
|
# be sending values...
|
||||||
throttleFailed = False
|
throttleFailed = False
|
||||||
for throttleRequest in request_iterator:
|
for throttleRequest in request_iterator:
|
||||||
|
print('Setting throttle to: ' + throttleRequest.throttle)
|
||||||
self.set_timeout(timeout_length)
|
self.set_timeout(timeout_length)
|
||||||
throttleFailed = self.motor.set_throttle(throttleRequest.throttle)
|
throttleFailed = self.motor.set_throttle(throttleRequest.throttle)
|
||||||
if throttleFailed:
|
if throttleFailed:
|
||||||
@@ -48,3 +51,11 @@ class MotorServicer(motorService_pb2_grpc.CarControlServicer):
|
|||||||
print("Node timeout elapsed")
|
print("Node timeout elapsed")
|
||||||
self.motor.stop()
|
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()
|
||||||
Reference in New Issue
Block a user