Buggy code:
public class IOIOCOmmunicationService extends IOIOService { public static final int PWN_MAX_FREQ = 10000 ; public static Map < Integer , Pin > pins ; public static CallbackContext eventListener ; public static final long delay = 100 ; public static boolean activeLed = true ; public static long lastCallbackFromJS = 0 ; public static long lastCallbackToJS = 0 ; public static void initPins ( ) { } public static void addAnalogInput ( int pinPort ) { } public static void addPwnOutput ( int pinPort , int freq ) { } public static void addDigitalOutput ( int pinPort ) { } public static void addDigitalInput ( int pinPort ) { } public static void setPwmOutput ( int pinPort , int freq ) { } public static void setDigitalOutput ( int pinPort , boolean output ) { } public static void toggleDigitalOutput ( int pinPort ) { } @ Override protected IOIOLooper createIOIOLooper ( ) { return new BaseIOIOLooper ( ) { private DigitalOutput led_ ; @ Override public void incompatible ( ) { JSONObject r = new JSONObject ( ) ; try { r . put ( "IOIOLIB_VER" , ioio_ . getImplVersion ( IOIOLIB_VER ) ) ; r . put ( "APP_FIRMWARE_VER" , ioio_ . getImplVersion ( APP_FIRMWARE_VER ) ) ; r . put ( "BOOTLOADER_VER" , ioio_ . getImplVersion ( BOOTLOADER_VER ) ) ; r . put ( "HARDWARE_VER" , ioio_ . getImplVersion ( HARDWARE_VER ) ) ; } catch ( Exception e ) { } PluginResult result = new PluginResult ( Status . ERROR , r ) ; result . setKeepCallback ( true ) ; IOIOCOmmunicationService . eventListener . sendPluginResult ( result ) ; } @ Override protected void setup ( ) throws ConnectionLostException , InterruptedException { led_ = ioio_ . openDigitalOutput ( LED_PIN ) ; for ( Integer pinPort : IOIOCOmmunicationService . pins . keySet ( ) ) { Pin pin = IOIOCOmmunicationService . pins . get ( pinPort ) ; if ( pin instanceof PinPwmOutput ) { PinPwmOutput pinPwmOutput = ( ( PinPwmOutput ) ( pin ) ) ; pinPwmOutput . pwmOutput = ioio_ . openPwmOutput ( pinPort , IOIOCOmmunicationService . PWN_MAX_FREQ ) ; } else if ( pin instanceof PinAnalogInput ) { PinAnalogInput pinAnalogInput = ( ( PinAnalogInput ) ( pin ) ) ; pinAnalogInput . analogInput = ioio_ . openAnalogInput ( pinPort ) ; } else if ( pin instanceof PinDigitalOutput ) { PinDigitalOutput pinDigitalOutput = ( ( PinDigitalOutput ) ( pin ) ) ; pinDigitalOutput . digitalOutput = ioio_ . openDigitalOutput ( pinPort ) ; } else if ( pin instanceof PinDigitalInput ) { PinDigitalInput pinDigitalInput = ( ( PinDigitalInput ) ( pin ) ) ; pinDigitalInput . digitalInput = ioio_ . openDigitalInput ( pinPort ) ; } } } @ Override public void loop ( ) throws ConnectionLostException , InterruptedException { if ( ( ( IOIOCOmmunicationService . lastCallbackFromJS ) == 0 ) || ( ( ( IOIOCOmmunicationService . lastCallbackToJS ) + ( IOIOCOmmunicationService . delay ) ) > ( System . currentTimeMillis ( ) ) ) ) { return ; } led_ . write ( IOIOCOmmunicationService . activeLed ) ; IOIOCOmmunicationService . activeLed = ! ( IOIOCOmmunicationService . activeLed ) ; IOIOCOmmunicationService . lastCallbackToJS = System . currentTimeMillis ( ) ; IOIOCOmmunicationService . lastCallbackFromJS = 0 ; JSONArray parameters = new JSONArray ( ) ; for ( Integer pinPort : IOIOCOmmunicationService . pins . keySet ( ) ) { Pin pin = IOIOCOmmunicationService . pins . get ( pinPort ) ; if ( ( IOIOCOmmunicationService . pins . get ( pinPort ) ) instanceof PinPwmOutput ) { PinPwmOutput pinPwmOutput = ( ( PinPwmOutput ) ( IOIOCOmmunicationService . pins . get ( pinPort ) ) ) ; pinPwmOutput . pwmOutput . setPulseWidth ( pinPwmOutput . freq ) ; try { parameters . put ( pinPwmOutput . getJson ( ) ) ; } catch ( Exception e ) { } } else if ( ( IOIOCOmmunicationService . pins . get ( pinPort ) ) instanceof PinAnalogInput ) { PinAnalogInput pinAnalogInput = ( ( PinAnalogInput ) ( IOIOCOmmunicationService . pins . get ( pinPort ) ) ) ; pinAnalogInput . output = pinAnalogInput . analogInput . read ( ) ; try { parameters . put ( pinAnalogInput . getJson ( ) ) ; } catch ( Exception e ) { } } else if ( pin instanceof PinDigitalOutput ) { PinDigitalOutput pinDigitalOutput = ( ( PinDigitalOutput ) ( pin ) ) ; <START_BUG> pinDigitalOutput . digitalOutput . write ( ( ! ( pinDigitalOutput . output ) ) ) ; <END_BUG> try { parameters . put ( pinDigitalOutput . getJson ( ) ) ; } catch ( Exception e ) { } } else if ( pin instanceof PinDigitalInput ) { PinDigitalInput pinDigitalInput = ( ( PinDigitalInput ) ( pin ) ) ; pinDigitalInput . input = pinDigitalInput . digitalInput . read ( ) ; try { parameters . put ( pinDigitalInput . getJson ( ) ) ; } catch ( Exception e ) { } } } PluginResult result = new PluginResult ( Status . OK , parameters ) ; result . setKeepCallback ( true ) ; IOIOCOmmunicationService . eventListener . sendPluginResult ( result ) ; } } ; } @ Override public void onStart ( Intent intent , int startId ) { } @ Override public IBinder onBind ( Intent arg0 ) { } }

Fix:
pinDigitalOutput . digitalOutput . write ( pinDigitalOutput . output ) ;