Use a stream for the steering as well.

This commit is contained in:
Piv
2019-11-24 13:12:55 +10:30
parent 070a87f285
commit d1695772b3
3 changed files with 7 additions and 7 deletions

View File

@@ -20,7 +20,7 @@ DESCRIPTOR = _descriptor.FileDescriptor(
package='MotorControl', package='MotorControl',
syntax='proto3', syntax='proto3',
serialized_options=None, serialized_options=None,
serialized_pb=_b('\n\x12motorService.proto\x12\x0cMotorControl\"#\n\x0fThrottleRequest\x12\x10\n\x08throttle\x18\x01 \x01(\x02\"\'\n\x10ThrottleResponse\x12\x13\n\x0bthrottleSet\x18\x01 \x01(\x08\"#\n\x0fSteeringRequest\x12\x10\n\x08steering\x18\x01 \x01(\x02\"\'\n\x10SteeringResponse\x12\x13\n\x0bsteeringSet\x18\x01 \x01(\x08\x32\xae\x01\n\nCarControl\x12P\n\x0bSetThrottle\x12\x1d.MotorControl.ThrottleRequest\x1a\x1e.MotorControl.ThrottleResponse\"\x00(\x01\x12N\n\x0bSetSteering\x12\x1d.MotorControl.SteeringRequest\x1a\x1e.MotorControl.SteeringResponse\"\x00\x62\x06proto3') serialized_pb=_b('\n\x12motorService.proto\x12\x0cMotorControl\"#\n\x0fThrottleRequest\x12\x10\n\x08throttle\x18\x01 \x01(\x02\"\'\n\x10ThrottleResponse\x12\x13\n\x0bthrottleSet\x18\x01 \x01(\x08\"#\n\x0fSteeringRequest\x12\x10\n\x08steering\x18\x01 \x01(\x02\"\'\n\x10SteeringResponse\x12\x13\n\x0bsteeringSet\x18\x01 \x01(\x08\x32\xb0\x01\n\nCarControl\x12P\n\x0bSetThrottle\x12\x1d.MotorControl.ThrottleRequest\x1a\x1e.MotorControl.ThrottleResponse\"\x00(\x01\x12P\n\x0bSetSteering\x12\x1d.MotorControl.SteeringRequest\x1a\x1e.MotorControl.SteeringResponse\"\x00(\x01\x62\x06proto3')
) )
@@ -192,7 +192,7 @@ _CARCONTROL = _descriptor.ServiceDescriptor(
index=0, index=0,
serialized_options=None, serialized_options=None,
serialized_start=193, serialized_start=193,
serialized_end=367, serialized_end=369,
methods=[ methods=[
_descriptor.MethodDescriptor( _descriptor.MethodDescriptor(
name='SetThrottle', name='SetThrottle',

View File

@@ -1,7 +1,7 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc import grpc
import MotorControl.motorService_pb2 as motorService__pb2 import motorService_pb2 as motorService__pb2
class CarControlStub(object): class CarControlStub(object):
@@ -19,7 +19,7 @@ class CarControlStub(object):
request_serializer=motorService__pb2.ThrottleRequest.SerializeToString, request_serializer=motorService__pb2.ThrottleRequest.SerializeToString,
response_deserializer=motorService__pb2.ThrottleResponse.FromString, response_deserializer=motorService__pb2.ThrottleResponse.FromString,
) )
self.SetSteering = channel.unary_unary( self.SetSteering = channel.stream_unary(
'/MotorControl.CarControl/SetSteering', '/MotorControl.CarControl/SetSteering',
request_serializer=motorService__pb2.SteeringRequest.SerializeToString, request_serializer=motorService__pb2.SteeringRequest.SerializeToString,
response_deserializer=motorService__pb2.SteeringResponse.FromString, response_deserializer=motorService__pb2.SteeringResponse.FromString,
@@ -37,7 +37,7 @@ class CarControlServicer(object):
context.set_details('Method not implemented!') context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') raise NotImplementedError('Method not implemented!')
def SetSteering(self, request, context): def SetSteering(self, request_iterator, context):
# missing associated documentation comment in .proto file # missing associated documentation comment in .proto file
pass pass
context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@@ -52,7 +52,7 @@ def add_CarControlServicer_to_server(servicer, server):
request_deserializer=motorService__pb2.ThrottleRequest.FromString, request_deserializer=motorService__pb2.ThrottleRequest.FromString,
response_serializer=motorService__pb2.ThrottleResponse.SerializeToString, response_serializer=motorService__pb2.ThrottleResponse.SerializeToString,
), ),
'SetSteering': grpc.unary_unary_rpc_method_handler( 'SetSteering': grpc.stream_unary_rpc_method_handler(
servicer.SetSteering, servicer.SetSteering,
request_deserializer=motorService__pb2.SteeringRequest.FromString, request_deserializer=motorService__pb2.SteeringRequest.FromString,
response_serializer=motorService__pb2.SteeringResponse.SerializeToString, response_serializer=motorService__pb2.SteeringResponse.SerializeToString,

View File

@@ -20,5 +20,5 @@ message SteeringResponse{
service CarControl{ service CarControl{
rpc SetThrottle(stream ThrottleRequest) returns (ThrottleResponse){} rpc SetThrottle(stream ThrottleRequest) returns (ThrottleResponse){}
rpc SetSteering(SteeringRequest) returns (SteeringResponse){} rpc SetSteering(stream SteeringRequest) returns (SteeringResponse){}
} }