Code Monkey home page Code Monkey logo

pipboy-elixir's Introduction

PipParser

This is an Elixir version of a parser for the Fallout 4 Pipboy protocol. It's also a chance to learn more about Elixir. My more complete implementation in Ruby can be found here, along with details on the protocol itself.

The Elixir version successfully parses messages from a binary stream, and will additionally parse messages of type 3 into full data updates.

Elixir's binary pattern matching turned out to be a stellar choice, and made parsing the binary stream far easier than Ruby. No surprise given Erlang's roots.

I also (for better or for worse) got to learn a little bit about macros.

Running it

PipParser takes input from STDIN. Below, we pipe a captured binary dump of some Pipboy traffic to PipParser.

$ mix run -e PipParser.run < test.bin
%PipUpdate{contents: "$General", id: 32140, type: :string}
%PipUpdate{contents: 72, id: 32156, type: :sint32}
%PipUpdate{contents: "Locations Discovered", id: 32155, type: :string}
%PipUpdate{contents: true, id: 32157, type: :bool}
%PipUpdate{contents: {[{32156, "value"}, {32155, "text"},
   {32157, "showIfZero"}], []}, id: 32154, type: :dict_update}
%PipUpdate{contents: 19, id: 32160, type: :sint32}
%PipUpdate{contents: "Locations Cleared", id: 32159, type: :string}
%PipUpdate{contents: true, id: 32161, type: :bool}
%PipUpdate{contents: {[{32160, "value"}, {32159, "text"},
   {32161, "showIfZero"}], []}, id: 32158, type: :dict_update}
%PipUpdate{contents: 24, id: 32164, type: :sint32}
%PipUpdate{contents: "Days Passed", id: 32163, type: :string}

Code

PipValues

A set of macros to provide short-hand syntax for various data types relevant to the Pipboy binary protocol (uint8, float32, etc).

PipStream

A custom Stream that pulls from STDIN, then extracts and emits tuples representing individual messages.

PipUpdate

Parsing functions for parsing Pipboy messages of type 3 a.k.a. data updates. Data updates are the most interesting form of data the Pipboy sends, and also the most complicated to parse.

Small examples of these parsing functions can be found in the tests (pip_update_test.exs).

PipParser

Right now there's a single run function in PipParser that shows a pipeline streaming data from STDIN, selecting messages of type 3, parsing the data upates, and printing them.

pipboy-elixir's People

Contributors

mattbaker avatar

Stargazers

 avatar Phil Pluckthun avatar Kyle Kelley avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.