public class

BinaryStreamer

extends VehicleMessageStreamer
java.lang.Object
   ↳ com.openxc.messages.streamers.VehicleMessageStreamer
     ↳ com.openxc.messages.streamers.BinaryStreamer

Class Overview

A class to deserialize and serialize binary-formatted vehicle messages from byte streams. The BinaryStreamer wraps the BinaryFormatter and handles messages delimiting. It uses standard message length delimiters as recommended by the protobuf docs and specific in the OpenXC message format. Unlike the BinaryFormatter, the BinaryStreamer is not stateless. It maintains an internal buffer of bytes so that if partial messages is received it can eventually receive an parse the entire thing.

Summary

Public Constructors
BinaryStreamer()
Public Methods
VehicleMessage parseNextMessage()
Deserialize and return the next messages from the internally buffered stream.
void receive(byte[] bytes, int length)
Add additional bytes to the buffer from the data source.
byte[] serializeForStream(VehicleMessage message)
Serialize the message and insert any required delimiters for insertion into a message stream.
[Expand]
Inherited Methods
From class com.openxc.messages.streamers.VehicleMessageStreamer
From class java.lang.Object

Public Constructors

public BinaryStreamer ()

Public Methods

public VehicleMessage parseNextMessage ()

Deserialize and return the next messages from the internally buffered stream.

Returns
  • the next deserialized VehicleMessage.

public void receive (byte[] bytes, int length)

Add additional bytes to the buffer from the data source.

Parameters
bytes an array of bytes received from the interface.
length number of bytes received, and thus the amount that should be read from the array.

public byte[] serializeForStream (VehicleMessage message)

Serialize the message and insert any required delimiters for insertion into a message stream.

Parameters
message the message to serialize.