Serialization and deserialization

Answering both questions with simplified code:

if (SerialPort.available() > 0) {
      for (Field field : fields) {
          Type type = field.getType();

          if (type == boolean.class) { field.setByte(this, SerialPort.readByte()); }
          else if (type == byte.class) { field.setByte(this, SerialPort.readByte()); }
          // ...

Reading Integer will be reading 4 bytes with

// Declared once somewhere
byte[] buffer = byte[4];
// ...
SerialPort.readBytes(buffer);
int value = convert_to_big_endian(buffer); // Or just use small ByteBuffer

Ok thank you very much!

But at least a short question… I switched on autocompletion in Procession. Now if I add a new file like SerialTransmission.java the autocompletion doesn’t work anymore in this sketch.

Doesn’t Processing support java files and autocompletion? Is there an workaround?
I’m not lazy, it’s just easier to find the right methods/variables :wink:

Tabs w/ “.java” file extensions are outta limits of PDE’s pre-processor. :see_no_evil:
In those kinda tabs, code has to be written w/ 100% Java compliant syntax. :coffee: