Skip to content

chesapeaketechnology/BufMonkey

Repository files navigation

BufMonkey

Protobuf support for Garmin's Monkey C programming language

Unsupported Features

  • Maps can be used with a workaround
  • Extensions and Services are currently not supported
  • Unknown fields are dropped
  • OneOf is not supported (yet)
  • Currently only decoding messages has been implemented

Runtime Library

The BufMonkey runtime library is a barrel file that can be included into your project in the same way that other barrels are included

Manually

Download the [BufMonkey barrel]() and drop it into your barrels folder of your Garmin application project. Update your jungle file to reference the barrel.

Eclipse

Download the BufMonkey barrel or clone this repo and follow the instructions for "How to include Barrels" on the Garmin Website.

Gradle-Garmin plugin

Barrels can be easily added to a project that use the [gradle-garmin plugin](https://github.com/chesapeaketechnology/gradle-garmin). Add the plugin to your gradle script and then reference the barrel using standard artifact notation as described in the [Barrel Dependencies](https://github.com/chesapeaketechnology/gradle-garmin#barrel-dependencies) section:

dependencies {
   barrel "com.test:my-awesome-barrel:1.0.0@barrel"
}

Generating Messages

Manual Generation

  • Download an appropriate protoc.exe and add the directory to the $PATH
  • Download protoc-gen-bufmonkey and extract the files into the same directory or somewhere else on the $PATH.
    • Running the plugin requires Java8 or higher to be installed
    • Protoc does have an option to define a plugin path, but it does not seem to work with the wrapper scripts
  • Call protoc with --bufmonkey_out=./path/to/generate

Protobuf Gradle Plugin

protobuf {
  ...
  // Locate the codegen plugins
  plugins {
    // Locate a plugin with name 'bufmonkey'. This step is optional.
    // If you don't locate it, protoc will try to use "protoc-gen-bufmonkey" from
    // system search path.
    bufmonkey {
      artifact = 'com.chesapeaketechnology:bufmonkey-generator:0.1.0'
      // or
      // path = 'tools/bufmonkey-generator'
    }
    // Any other plugins
    ...
  }
  ...
}

Usage

Import

Import your generated classes module to your Monkey c class:

using BufMonkey.com.test;

Notes:

  • Class module path is controlled by the package path defined in your proto file
  • All generated classes will be generated under the BufMonkey namespace.

Decoding

Decoding Protobuf messages is as simple as creating the type you want to deserialize to and then passing the protobuf byte array to the decode method.

using BufMonkey.com.test;

...

function myMethod(bytes) {
    var generated = new test.MyGeneratedClass();
    generated.decode(bytes);
}

...

About

Protobuf support for Garmin's Monkey C programming language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published