ByteArts
Members-
Posts
6 -
Joined
-
Last visited
Content Type
Profiles
Forums
Developer Articles
KSP2 Release Notes
Bug Reports
Everything posted by ByteArts
-
I'm new to programming with kRPC and am working on a program that uses the TCP/IP sockets interface to communicate with kRPC (my goal is to make a mobile app that can interact with kRPC using just sockets with no other dependencies). To learn how to use the protocol, I'm using Python on my Windows PC and KSP 1.3, following the examples in the documentation. I'm able to connect and get the KRPC.GetStatus command to work, but am having problems getting the UI.Message command to work. Here's the code I'm trying to use: import socket from time import sleep from google.protobuf.internal.encoder import _VarintEncoder from google.protobuf.internal.decoder import _DecodeVarint from krpc.schema import KRPC_pb2 as KRPC """ support functions (e.g. send_message()) omitted for clarity -- see kRPC documents for examples. """ # connect over socket to kRPC, request status call = KRPC.ProcedureCall() call.service = 'KRPC' call.procedure = 'GetStatus' request = KRPC.Request() request.calls.extend([call]) send_message(rpc_conn, request) # Receive the response response = recv_message(rpc_conn, KRPC.Response) # Check for an error in the response if response.HasField('error'): raise RuntimeError('ERROR: ' + str(response.error)) # Check for an error in the results assert(len(response.results) == 1) if response.results[0].HasField('error'): raise RuntimeError('ERROR: ' + str(response.error)) # Decode the return value as a Status message status = KRPC.Status() status.ParseFromString(response.results[0].value) # Test UI.Message() print 'Invoking UI.Message' call = KRPC.ProcedureCall() call.service = 'UI' call.procedure = 'Message' arg = KRPC.Argument() arg.position = 0 arg.value = 'nice ship you have there' call.arguments.extend([arg]) request = KRPC.Request() request.calls.extend([call]) send_message(rpc_conn, request) # Receive the response response = recv_message(rpc_conn, KRPC.Response) # Check for an error in the response if response.HasField('error'): raise RuntimeError('ERROR: ' + str(response.error)) # Check for an error in the response assert(len(response.results) == 1) if response.results[0].HasField('error'): raise RuntimeError('ERROR: ' + str(response.error)) I'm guessing that I'm not initializing the arguments to UI.Message properly? I don't get any errors or any response from kRPC after the initial response from the GetStatus command. Thanks for any help!
-
I'm just getting started with a project that will use a mobile device to interact with KSP via a socket connection and kRPC. I'm using the socket interface because I can't use the provided client framework (at least not easily) on all the different platforms I'm targeting (iOS, Android, macOS, and Windows). I already have working code (in Delphi on Windows, Mac, Android and iOS) that makes the connection to kRPC and processes the protocol buffer data, but am having problems figuring out the next steps, namely how to figure out the names of the other available services and procedures that can be accessed using the socket interface in kRPC. I've tried using the KRPC.GetServices procedure, but it returns over 300KB of data -- is there a way to just enumerate the available services first, and then query them individually to get more info? Any info, advice, or comments are welcome. Thanks!