Jump to content

ByteArts

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by ByteArts

  1. Thanks! I am working on my own cross-platform (Windows, Android, iOS and macOS) client library, so this will be helpful. I'm basing my implementation on this: https://blog.grijjy.com/2017/04/25/binary-serialization-with-google-protocol-buffers/
  2. Anyone know what the "Debug logging" option in the kRPC configuration dialog does and how to use it? I was hoping to watch the calls I'm making to see if I'm sending the data right. Thanks, Scott
  3. Thanks so much! That makes sense. I was thinking that SerializeToString() in send_message() took care of that, but obviously I was wrong. Protocol buffers are a pretty powerful and flexible mechanism, but can be quite complicated to debug when something isn't working!
  4. 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!
  5. Thanks -- I was looking for that. The link to the kRPC forum from the kRPC git page is broken.
  6. 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!
×
×
  • Create New...