define packet based protocols in a declarative fashion
Ruby
Latest commit 9d44913 Feb 18, 2017 @levinalex Merge branch 'updates'
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
Gemfile
History.txt
LICENSE
README.md
Rakefile
packet_io.gemspec

README.md

packet_io

by Levin Alexander
http://levinalex.net/

Build Status

DESCRIPTION:

packet_io is a small library that makes it easy to define packet based protocols over a serial link (RS232) in a declarative fashion.

SYNOPSIS:

require 'packet_io'

# define your protocol handler, inheriting from PacketIO::Base
#
# override `read` and `write` to implement your functionality
#
# this is a simple protocol handler that does nothing.
#
# see {PacketIO::LineBasedProtocol} for another trivial example
#
class MyNOPProtocol < PacketIO::Base
  def receive(packet)
    forward(packet)
  end

  def write(data)
    super(packet)
  end
end

# use your protocol. It is possible to stack multiple protocol
# layers on top of each other
#
stream = PacketIO.IOListener(File.open("/dev/ttyUSB0"))
line_based = PacketIO::LineBasedProtocol.new(stream)
my_protocol = MyNOPProtocol.new(line_based)


stream.run!

INSTALL:

gem install packet_io