firmata4j
firmata4j copied to clipboard
Cannot start the firmata device because the port is 'busy' stack trace
i keep getting error this stack trace to be exact
java.io.IOException: Cannot start firmata device java.io.IOException: Cannot start firmata devi Caused by: jssc.SerialPortException: Port name - /dev/tty.usbmodem14501; Method name - openPort(); Exception type - Port busy.
heres my code ` if (device == null) { try { device = new FirmataDevice(COM_PORT); device.start(); device.ensureInitializationIsDone();
//initialize pin (just like how you initialize in Arduino IDE)
BUTTON_UP = device.getPin(2);
BUTTON_RIGHT = device.getPin(3);
BUTTON_DOWN = device.getPin(4);
BUTTON_LEFT = device.getPin(5);
BUTTON_E = device.getPin(6);
BUTTON_F = device.getPin(7);
Pin[] Buttonpins = {BUTTON_DOWN, BUTTON_LEFT, BUTTON_RIGHT, BUTTON_UP, BUTTON_E, BUTTON_F, JOYSTICK_BUTTON};
for (Pin pin : Buttonpins){
pin.setMode(Pin.Mode.INPUT);
}
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
and i am also getting a error Cannot invoke "org.firmata4j.Pin.setMode(org.firmata4j.Pin$Mode)" because "pin" is null
how is pin null when i initialized in the code above