Buscar
Social
Ofertas laborales ES

Foro sobre Java SE > Java para comunicar Arduino y Raspberry usando firmata

Intento comunicar Raspberry con Arduino usando firmata


El codigo que uso es bastante simple :

public class Serial {


public static void main(String[] args)throws Exception{

IODevice device = new FirmataDevice("/dev/ttyACM0"); // construct the Firmata device instance using the name of a port

device.start(); // initiate communication to the device
device.ensureInitializationIsDone(); // wait for initialization is done
// sending commands to the board



Pin pin = device.getPin(11);

pin.setMode(Pin.Mode.OUTPUT);
while(true){
pin.setValue(1);
Thread.sleep(1000);
pin.setValue(0);
Thread.sleep(1000);

}
// TODO code application logic here
}

}
y para el arduino ejecuto el codigo de los ejemplos de firmata standar


pero me arroja este error :
Exception in thread "EventThread /dev/ttyACM0" java.lang.ArrayIndexOutOfBoundsException: 11
at org.firmata4j.firmata.FirmataDevice.onCapabilitiesReceive(FirmataDevice.java:349)
at org.firmata4j.firmata.FirmataDevice.access$300(FirmataDevice.java:59)
at org.firmata4j.firmata.FirmataDevice$1.onEvent(FirmataDevice.java:77)
at org.firmata4j.fsm.AbstractState.publish(AbstractState.java:79)
at org.firmata4j.firmata.parser.ParsingCapabilityResponseState.process(ParsingCapabilityResponseState.java:63)
at org.firmata4j.fsm.FiniteStateMachine.process(FiniteStateMachine.java:135)
at org.firmata4j.fsm.FiniteStateMachine.process(FiniteStateMachine.java:160)
at org.firmata4j.fsm.FiniteStateMachine.process(FiniteStateMachine.java:146)
at org.firmata4j.firmata.FirmataDevice.serialEvent(FirmataDevice.java:247)
at jssc.SerialPort$LinuxEventThread.run(SerialPort.java:1299)
Exception in thread "main" java.lang.InterruptedException: Connection timeout
at org.firmata4j.firmata.FirmataDevice

mayo 27, 2018 | Unregistered CommenterFiore