@ Override public void process ( byte b ) { if ( b == END_SYSEX ) { byte [ ] buffer = convertI2CBuffer ( getBuffer ( ) ) ; byte address = buffer [ 0 ] ; byte register = buffer [ 1 ] ; byte [ ] message = new byte [ buffer . length - 2 ] ; System . arraycopy ( buffer , 2 , message , 0 , buffer . length - 2 ) ; Event event = new Event ( I2C_MESSAGE ) ; event . setBodyItem ( I2C_ADDRESS , address ) ; event . setBodyItem ( I2C_REGISTER , register ) ; event . setBodyItem ( I2C_MESSAGE , message ) ; transitTo ( WaitingForMessageState . class ) ; publish ( event ) ; } else { bufferize ( b ) ; } }
Collects I2C message from individual bytes .