Hi,
I just came across this thread because I had the same question. After I did not find any ready-made solution I started to work on it myself. It tumed out to be quite easy to get processing to talk with the arduino via EasyTransfer. Just make sure you have your data stored in an array of chars:
void et_send(Serial port, char[] buffer) {
byte checksum = (byte) buffer.length;
port.write((byte)0x06); // these magic bytes define the start
port.write((byte)0x85); // of a message for EasyTransfer.
port.write((byte)checksum); // The starter is followed by the length of the payload...
for (int i = 0; i < buffer.length; i++) {
port.write((byte)buffer[i]); // ...the payload itself...
checksum ^= buffer[i];
}
port.write((byte)checksum); // ...and a checksum (the length and each payload byte xor'ed)
}
To send data other than plain chars it would have to be prepared for sending with the above function, like so (example for int and String):
char[] et_prepareMessage(String toSend) {
char[] buffer = new char[toSend.length()];
for (int i = 0; i < toSend.length(); i++) {
buffer[i] = toSend.charAt(i);
}
return buffer;
}
char[] et_prepareMessage(int toSend) {
char[] buffer = new char[4];
buffer[0] = (char) (toSend & 0xFF);
buffer[1] = (char)((toSend >> 8) & 0xFF);
buffer[2] = (char)((toSend >> 16) & 0xFF);
buffer[3] = (char)((toSend >> 24) & 0xFF);
return buffer;
}
Write other 'prepare' methods for other types of data. To assemble a full paket with different values use the concat(a, b) function.
Hope it helps someone,
Micha