Skip to content

Instantly share code, notes, and snippets.

@djungelorm
djungelorm / communication.cpp
Created November 14, 2018 22:55
kRPC fixes for Arduino Due
#include <krpc/communication.h>
#include <krpc/error.h>
#if defined(KRPC_COMMUNICATION_POSIX)
#include <fcntl.h>
#include <stdint.h>
#include <unistd.h>
@djungelorm
djungelorm / suborbitalflight.ino
Created April 10, 2018 07:29
Sub-orbital flight kRPC demo for Arduino
#include <krpc.h>
#include <krpc/services/krpc.h>
#include <krpc/services/space_center.h>
const int BUTTON = 2;
const int LED = 13;
HardwareSerial * conn;
#ifdef KRPC_ERROR_CHECK_FN
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.
"""
@djungelorm
djungelorm / gist:f19163ee8c68c16f9e4f253a3b464ece
Last active March 7, 2018 20:48
kRPC C++ client with CodeBlocks and MSYS2
Download and install MSYS2 64bit (http://www.msys2.org/), follow the installation instructions and update it (say yes if asked to remove conflicting packages)
Open MSYS2 and run the following command to install required packages:
pacman -S base-devel unzip mingw-w64-x86_64-gcc mingw-w64-x86_64-binutils
Download the following files to C:/msys64/home/<your username>
* protobuf-cpp-3.4.1.zip from https://github.com/google/protobuf/releases
* asio-1.10.6.zip from https://sourceforge.net/projects/asio/files/asio/1.10.6%20%28Stable%29/
* krpc-cpp-0.4.4.post1.zip from https://github.com/krpc/krpc/releases/tag/v0.4.4.post1.cpp
1. Install CodeBlocks (without MinGW if possible, as we will need to use a separate installation of MinGW anyway)
2. Download mingw-get-setup.exe from https://sourceforge.net/projects/mingw/files/Installer
Run mingw-get-setup.exe and install MinGW to C:\MinGW
(Note: It is essential that this path does not contain any spaces.)
When the installation manager window appears, mark the following for installation:
mingw32-base
mingw32-gcc-g++
msys-base
msys-autoconf (class bin)
msys-libtool (class bin)
diff --git a/tools/build/python.bzl b/tools/build/python.bzl
index 1fabdf4..dbcf603 100644
--- a/tools/build/python.bzl
+++ b/tools/build/python.bzl
@@ -14,10 +14,10 @@ def _create_py_env(out, install):
tmp = out+'.tmp-create-py-env.$$'
cmds = [
'rm -rf %s' % tmp,
- 'virtualenv %s --quiet --never-download --no-site-packages' % tmp
+ 'virtualenv %s --never-download --no-site-packages' % tmp
@djungelorm
djungelorm / orbit.py
Created July 18, 2017 18:33
Script for testing orbital parameters
import krpc
import time
import math
conn = krpc.connect()
vessel = conn.space_center.active_vessel
orbit = vessel.orbit
ut = conn.add_stream(getattr, conn.space_center, 'ut')
def rad_to_deg(rad):
@djungelorm
djungelorm / index.html
Created June 20, 2017 17:04
sphinx-tabs example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Fruits &#8212; Tabs Examples 0.2 documentation</title>
'use strict'
var websocket = require('ws');
var protobufjs = require('protobufjs')
var proto = protobufjs.loadProtoFile('krpc.proto').build();
console.log('Connecting to RPC server')
let rpcConn = new websocket('ws://127.0.0.1:50000')
rpcConn.binaryType = 'arraybuffer'
'use strict';
var WebSocket = require('ws');
var ProtoBuf = require('protobufjs')
var builder = ProtoBuf.loadProtoFile('krpc.proto'),
proto = builder.build();
function decodeBytes(buffer) {
return buffer.slice(5)