Hello everybody,
I have a problem with the DecaWave MDEK1001 Development Kit.
I set up the modules as in the description and then connected them to my computer via USB.
Then I can start tracking using Tera Term.
The position data is sent as required.
Now I would like to integrate this function into a Java application for a research project.
I start the listener, but do not get any position data back.
If I connect to Tera Term once (doing nothing) and then restart the Java application without sending the “les” command, everything works.
I cannot explain the behavior to myself.
Have i forgotten anything?
Had anyone the same problem and how could I solve it.
Attached you can find a test class in java, where the operations should be implemented correctly.
I also tried this simple function in python (start listener and get position data).
But also there I have the same problem.
Thanks in advance for the support
best regards
static CommPortIdentifier portId;
// settings for port
private static String usedPort = "COM5";
private static int baudrate = 115200;
private static int dataBits = SerialPort.DATABITS_8;
private static int stopBits = SerialPort.STOPBITS_1;
private static int parity = SerialPort.PARITY_NONE;
private static SerialPort serialPort = null;
private static OutputStream outputstream;
private static BufferedReader br = null;
public static void startUWBModules() {
portId = findPort();
openPort();
startCommunication();
openPort();
waitForMessage();
}
private static CommPortIdentifier findPort() {
// try to get port
try {
portId = CommPortIdentifier.getPortIdentifier(usedPort);
} catch (NoSuchPortException e) {
System.out.println("Log: Error!!! Port can't be found!");
e.printStackTrace();
}
System.out.println("Log: Port found.");
return portId;
}
private static void openPort() {
// Open connection with serial port
try {
// open port
serialPort = (SerialPort) portId.open("SimpleWriteApp", 20000);
// set setting for opened port
try {
serialPort.setSerialPortParams(baudrate, dataBits, stopBits, parity);
serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
} catch (UnsupportedCommOperationException e) {
System.out.println("Log: Error!!! Settings for port can't be done!");
e.printStackTrace();
}
} catch (PortInUseException e) {
System.out.println("Log: Error!!! Port can't be opened!");
e.printStackTrace();
}
try {
outputstream = serialPort.getOutputStream();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static void startCommunication()
{
try {
outputstream.write("\r\r".getBytes());
outputstream.flush();
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
outputstream.write("les\r".getBytes());
//outputstream.write(0x0D);
//outputstream.flush();
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
outputstream.flush();
outputstream.close();
serialPort.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static void waitForMessage()
{
try {
br = new BufferedReader(new InputStreamReader(serialPort.getInputStream()));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String line = null;
try {
line = br.readLine();
while((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}