Questions tagged [preon]

Preon aims to provide a framework for dealing with binary encoded data; or more specifically, it aims to deal with situations in which bytes are considered to be overkill.

Preon aims to provide a framework for dealing with binary encoded data; or more specifically, it aims to deal with situations in which bytes are considered to be overkill. The project is named after the "point-like" particles, conceived to be subcomponents of quarks and leptons. Let's just say very small particles that you don't see with the naked eye, but you probably rely on them without knowing.

24 questions
8
votes
2 answers

Java or C++ equivalents to Preon?

Preon is a Java library meant for creating binary codecs: you simply place annotations in a class' data members regarding their correspondence with bit fields (e.g. number of bits to use for certain field) and, based on such class, the library…
noe
  • 1,684
  • 1
  • 17
  • 35
3
votes
1 answer

How to parse different packet types depending on first byte

I'm trying to parse mysql result packets using preon. Packet looks like this: nn xx yy yy yy zz zz zz I parse it like this class ResponsePacket { @BoundNumber(size="1") byte sizeOfThePacket; /* if(xx==00) packet = OkResponsePayload(yy…
Łukasz
  • 123
  • 1
  • 2
  • 6
3
votes
2 answers

Preon on Android

I tried to run a sample Preon application on Android 2.1 without luck. I wonder if running a Preon application on Android is even possible. How hard would it be to make the Preon framework Dalvik friendly? Preon is a Java library for building codecs…
Oscar Montoya
  • 177
  • 1
  • 8
3
votes
1 answer

Parsing opcodes with Kaitai Struct

Doing my first steps in Kaitai Struct, I've been trying to do BSON parser as an excercise. My .ksy code that parses BSON element now looks like that: element: seq: - id: el_type type: u1 enum: bson_type - id:…
2
votes
0 answers

How can I model a Array with Arrays in preon

I have a problem here with problem I tried several things I just can't get it to init probably. @TypePrefix(value = "4", size = 8) public class ArrayObject extends SerializedData { @BoundBuffer(match = {(byte) 0x00, (byte) 0x01}) private…
Mark Bakker
  • 1,278
  • 8
  • 19
2
votes
1 answer

Preon unable to encode/decode little endian

Background I am attempting to use the preon library to encode/decode binary data. My 1 byte structure works fine when I configure the byte order for big endian, but fails for little endian. It appears that the endianess effects the intra-byte data…
R Dub
  • 678
  • 6
  • 23
2
votes
2 answers

Read file headers using java

I am trying to read file headers using java, I want to get file type(image, audio whatever). I have tried many examples but nothing seems to work. I tried preon and no luck, can some one tell me how to read file headers using preon or some other…
Eric
  • 1,171
  • 2
  • 14
  • 27
1
vote
1 answer

Signed und Unsigned Integers in Preon

I want to use Preon for project that communicates with a server written in C. The protocol depends on the native endianess of the machine (you can solve with thisjava.nio.ByteOrder.getNative() under the assumption that the JVM has the same endianess…
user141335
1
vote
1 answer

How do I install Preon?

I am trying to install preon and run it within IntelliJ. I have downloaded the source code from https://github.com/preon/preon. Then I open the project with IntelliJ. Then I download pecia and import it as a module into the preon project. Then…
ClarkS
  • 100
  • 1
  • 9
1
vote
1 answer

Preon decode and then encode doesn't return the same byte array

I am using Preon to encode enum fields in a byte array. The fields of the first byte (example-byte: 0xf7=1111 01 11) are set up as this: @BoundNumber(size="2") //Corresponds to 11 private byte b1_1_notUsed; @BoundNumber(size="2") //Corresponds to…
JohnyTex
  • 3,323
  • 5
  • 29
  • 52
1
vote
1 answer

Get size and offset of an object field with Preon

I am developing a shared objects editor/viewer for eclipse using Preon. The editor looks like: To improve it, I would like to implement a function that, once selected an entry on the top pannel, it would highlight the corresponding bytes on the…
Marco Nanni
  • 113
  • 2
  • 6
0
votes
1 answer

variable length sequence, first bit indicating end of sequence, preon

How would you parse a variable length sequence of bytes where first bit (BigEndian) indicates if another byte is following using Preon? Example byte[] bytecode = new byte[] { (byte) 0xf2, (byte) 0xbf, (byte) 0xbf, (byte) 0xbf,…
Dusan
  • 115
  • 1
  • 7
0
votes
1 answer

Byte alignment problem using Preon

Hello everybody :) I am currently using preon for a spare time project, and I have encountered the following problem: I am trying to read a fixed length String with the following code: @Bound int string_size; @ByteAlign @BoundString(size =…
0
votes
0 answers

Binary parsing in Swift like Preon in Java

I need to parse binary data using Swift. Can anybody tell me how to implement something like the Java Preon library in Swift? QByte, here is more information.... I am developing an application to program radios. The program must read and write data…
ClarkS
  • 100
  • 1
  • 9
0
votes
1 answer

Multiple @ImportStatic annotations on a single class using the Java Preon library

I'm wondering if there is a way to use multiple @ImportStatic annotations for a single class with Preon? I tried: @ImportStatic(classA.class) @ImportStatic(classB.class) // Also tried: @ImportStatic(classA.class classB.class) // And:…
ged
  • 33
  • 8
1
2