Hi guys, Im still pretty new to the world of robotics and programming, I am trying to create a controller for my robot in java, Im using the demalanovue board, I have managed to find a sketch which works using hyperterminal and the serial monitor, however when I try to run it using my java program theres a little light labelled L next to the power, rx and tx leds that flashes a couple of times, giving me the impression the data is being recieved! does anybody know if my assumption is correct and have any ideas, btw, my board is a dfrobot version of the demalanovue not the actual!
a copy of my java code is shown below if anyone wishes to have a look,
import javax.comm.;
import java.io.;
import java.util.*;
public class ComControl {
/**
-
@param args the command line arguments
*/
static CommPortIdentifier portid;
static CommPortIdentifier portid1;
InputStream inputStream;
OutputStream outputStream;
SerialPort serialPort1, serialPort2;
Thread readThread;
protected int divertCode = 1;
static String TimeStamp;
public static void main(String[] args) {
// TODO code application logic here
try {
portid = CommPortIdentifier.getPortIdentifier("COM3");
portid1 = CommPortIdentifier.getPortIdentifier("COM4");
ComControl reader = new ComControl();
}
catch
(Exception e) {
TimeStamp = new java.util.Date().toString();
System.out.println(TimeStamp + ": COM3 " + portid);
System.out.println(TimeStamp + ": COM4 " + portid1);
System.out.println(TimeStamp + ": msg1 - " + e);
}
};
public ComControl(){
try {
TimeStamp = new java.util.Date().toString();
serialPort1 = (SerialPort) portid1.open("ComControl", 2000);
System.out.println(TimeStamp + ": " + portid1.getName() + " opened for sending data");
}
catch (PortInUseException e) {}
try {
serialPort1.setSerialPortParams(9600,
SerialPort.DATABITS_7,
SerialPort.STOPBITS_1,
SerialPort.PARITY_EVEN);
} catch (UnsupportedCommOperationException e) {}
try{
outputStream = serialPort1.getOutputStream();
outputStream.write(divertCode);
System.out.println(TimeStamp + ": data sent");
outputStream.close();
} catch (IOException e) {}
}
}