|
|||||||||||
| PREV NEXT | FRAMES NO FRAMES | ||||||||||
See:
Description
| Packages | |
| com.msi.comms.bytebuffer | Byte Buffer toolkit. |
Byte Buffer - toolkit for creating and managing byte buffers.
Given a buffer layout:
msgid cmd parm 1 parm 2
[-----][---][--------][--------]
This creates a fixed buffer:
FixedBuffer buf = new FixedBuffer(24);
buf.addCell("Message ID", 5); // index 0
buf.addCell("Command", 3); // index 1
buf.addCell("Parameter 1", 8); // index 2
buf.addCell("Parameter 2", 8); // index 3
Cells are windows overlaying a fixed length byte array. The cells allow for individual read/write access to the bytes within the buffer associated with that cell.
Cells are catenated from the buffer start (byte 0 of the buffer). The specified name is used in toString output and the numeric argument specifies the length of the cell.
Individual cells are accessed by index, starting at zero for msgid using the getCell and setCell methods.
Supported buffer operations include clearBuffer to set all the data to a specified byte value and setBuffer to load the underlying data buffer with the contents of a specified byte array.
Example:
FixedBuffer buf = new FixedBuffer(24);
buf.addCell("Message ID", 5); // index 0
buf.addCell("Command", 3); // index 1
buf.addCell("Parameter 1", 8); // index 2
buf.addCell("Parameter 2", 8); // index 3
byte [] rawData = new byte[24];
inStream.read(rawData);
buf.setBuffer(rawData);
System.out.println("Message ID = " + getCellText(0));
|
|||||||||||
| PREV NEXT | FRAMES NO FRAMES | ||||||||||