LusoRobótica - Robótica em Português

Sistemas específicos => Arduino / AVR => Tópico iniciado por: oxytech em 04 de Novembro de 2010, 18:04

Título: arduino+java
Enviado por: oxytech em 04 de Novembro de 2010, 18:04
boas!

estava a tentar seguir este tutorial ( http://www.arduino.cc/playground/Interfacing/Java (http://www.arduino.cc/playground/Interfacing/Java) ) para por o arduino a comunicar com java, mas não estou a conseguir compilar....


Código: [Seleccione]


C:\Users\...>javac SerialTest.
java
SerialTest.java:3: package gnu.io does not exist
import gnu.io.CommPortIdentifier;
             ^
SerialTest.java:4: package gnu.io does not exist
import gnu.io.SerialPort;
             ^
SerialTest.java:5: package gnu.io does not exist
import gnu.io.SerialPortEvent;
             ^
SerialTest.java:6: package gnu.io does not exist
import gnu.io.SerialPortEventListener;
             ^
SerialTest.java:9: cannot find symbol
symbol: class SerialPortEventListener
public class SerialTest implements SerialPortEventListener {
                                   ^
SerialTest.java:10: cannot find symbol
symbol  : class SerialPort
location: class SerialTest
        SerialPort serialPort;
        ^
SerialTest.java:83: cannot find symbol
symbol  : class SerialPortEvent
location: class SerialTest
        public synchronized void serialEvent(SerialPortEvent oEvent) {
                                             ^
SerialTest.java:27: cannot find symbol
symbol  : class CommPortIdentifier
location: class SerialTest
                CommPortIdentifier portId = null;
                ^
SerialTest.java:28: cannot find symbol
symbol  : variable CommPortIdentifier
location: class SerialTest
                Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();
                                       ^
SerialTest.java:32: cannot find symbol
symbol  : class CommPortIdentifier
location: class SerialTest
                        CommPortIdentifier currPortId = (CommPortIdentifier) por
tEnum.nextElement();
                        ^
SerialTest.java:32: cannot find symbol
symbol  : class CommPortIdentifier
location: class SerialTest
                        CommPortIdentifier currPortId = (CommPortIdentifier) por
tEnum.nextElement();
                                                         ^
SerialTest.java:48: cannot find symbol
symbol  : class SerialPort
location: class SerialTest
                        serialPort = (SerialPort) portId.open(this.getClass().ge
tName(),
                                      ^
SerialTest.java:53: cannot find symbol
symbol  : variable SerialPort
location: class SerialTest
                                        SerialPort.DATABITS_8,
                                        ^
SerialTest.java:54: cannot find symbol
symbol  : variable SerialPort
location: class SerialTest
                                        SerialPort.STOPBITS_1,
                                        ^
SerialTest.java:55: cannot find symbol
symbol  : variable SerialPort
location: class SerialTest
                                        SerialPort.PARITY_NONE);
                                        ^
SerialTest.java:84: cannot find symbol
symbol  : variable SerialPortEvent
location: class SerialTest
                if (oEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
                                             ^
16 errors

C:\Users\Oxigen_cult\Desktop\arduino-0021\~~programas\com.java>

ao que parece faltam as bibliotecas não é? mas segundo o tutorial:
Citar
RXTX Library Set Up

If you installed the Arduino IDE, you already have the RXTX library installed for the next steps, and you may be able to skip this section and start with the sample Java code.


há aqui qualquer coisa que me esta a escapar  ::)
Título: Re: arduino+java
Enviado por: CBX em 04 de Novembro de 2010, 18:19
tens a biblioteca na pasta do java?
Título: Re: arduino+java
Enviado por: oxytech em 04 de Novembro de 2010, 18:30
nop, é esta a pasta?

Citar
C:\Program Files\Java\jdk1.6.0_21\lib

copio o rxtxSerial.dll que esta na pasta do arduino para essa pasta mas não compila a mesma...
Título: Re: arduino+java
Enviado por: CBX em 04 de Novembro de 2010, 19:10
vai a rxtx.org e faz download da biblioteca mais recente.

dentro do zip encontras o ficheiro "RXTXcomm.jar" que vai para a pasta ...\Java\jre1.6.0_21\lib\ext\ e o ficheiro "rxtxSerial.dll" para a pasta ...\Java\jre1.6.0_21\bin\

assim já deve funcionar  ;)
Título: Re: arduino+java
Enviado por: oxytech em 04 de Novembro de 2010, 19:33
vai a rxtx.org e faz download da biblioteca mais recente.

dentro do zip encontras o ficheiro "RXTXcomm.jar" que vai para a pasta ...\Java\jre1.6.0_21\lib\ext\ e o ficheiro "rxtxSerial.dll" para a pasta ...\Java\jre1.6.0_21\bin\

assim já deve funcionar  ;)

fiz isso (não tinha  a pasta ext, por isso criei uma, copiei o .jar para a a ext e mantive uma copia também na pasta lib) e continua na mesma :S

Título: Re: arduino+java
Enviado por: CBX em 04 de Novembro de 2010, 19:48
experimenta a copiar também o "rxtxParallel.dll", mais não te posso ajudar, isto é o que eu faço para um programa que aqui tenho em java funcionar, de java não percebo nada...
Título: Re: arduino+java
Enviado por: oxytech em 04 de Novembro de 2010, 20:02
experimenta a copiar também o "rxtxParallel.dll", mais não te posso ajudar, isto é o que eu faço para um programa que aqui tenho em java funcionar, de java não percebo nada...

sim pus também esse ficheiro.

ok, obrigado pela ajuda que já deste  :)