Giter Club home page Giter Club logo

protocol-tools's Introduction

protocol-tools

Just a small collection of tools to parsing simple character oriented protocols. ARINC 618 is a public communications spec that shows off what the ByteProtocol class can do:

Easily create new messages from scratch:

>>> message = Acars618.assemble({'text': 'Hello, world!', 'tail':'WG12345'})
>>> print "Message:", repr(message)
Message: '\x012WG12345\x15H11\x02M01AUA9090Hello, world!\x03'

Parse out a message into individual fields:

>>> values, spans = parsedMessage = Acars618.detect(message)
>>> print "Fields:", repr(values)
Fields: {'dbi': '1', 'flight': '9090', 'ack': '\x15', 'soh': '\x01', 'agency': 'UA', 'label': 'H1', 'msn': 'M01A', 'tail': 'WG12345', 'mode': '2', 'text': 'Hello, world!', 'trailer': '\x03', 'sot': '\x02'}

Change selected fields of an example protocol string:

>>> newMessage = Acars618.mutate(message, {'text': "I'm Replaced!"})
>>> print "New Message:", repr(newMessage)
New Message: "\x012WG12345\x15H11\x02M01AUA9090I'm Replaced!\x03"

Given two example strings, show the fields that have different values:

>>> diffs = Acars618.difference(message, newMessage)
>>> print "Differences:", repr(diffs)
Differences: ['text']

Censor a selection of fields:

>>> censoredMessage = Acars618.censor(message, parseCensorFields=['text', 'tail'])
>>> print "Censored Message", repr(censoredMessage)
Censored Message '\x012!!!!!!!\x15H11\x02M01AUA9090!!!!!!!!!!!!!\x03'

protocol-tools's People

Contributors

wagoodman avatar

Stargazers

 avatar

Watchers

 avatar  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.