Skip to content
Snippets Groups Projects
Commit 146d3d41 authored by Fabian Di Taranto's avatar Fabian Di Taranto
Browse files

No commit message

No commit message
parent 507fc538
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-12">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
......
......@@ -15,11 +15,11 @@ public class Encoder {
byte[] b = model.getConnection().writeData("ge\r\n".getBytes());
if (b != null && b.length >= 7) {
if (b[0] == 'r') {
int i = 3;
int i = 4;
String ret = "";
do {
ret += "" + (char)b[i++];
} while (i<=6);
} while (i<=7);
try {
return Integer.parseInt(ret, 16);
} catch (NumberFormatException e){
......
......@@ -24,10 +24,11 @@ public class UART {
if (b.length >= 3) {
if (b[0] == 'r') {
for (int i = 1; i < b.length-1; i++) {
if (b[0] != '\r'){
if (b[i] != '\r' && b[i] != '\n'){
ret += (char)b[i];
}
}
System.out.println(ret);
}
}
}
......
......@@ -29,17 +29,19 @@ public class UARTView extends JPanel implements ActionListener, View {
this.add(rxTextField);
this.setBorder(new TitledBorder("UART"));
uart = new UART(model);
model.addView(this);
}
public void update() {
rxTextField.setText(uart.getString());
if (rxTextField.getText().length() > 50) rxTextField.setText("");
rxTextField.setText(rxTextField.getText() + uart.getString());
if (rxTextField.getText().length() > 20) rxTextField.setText("");
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(txTextField)) {
uart.sendString(txTextField.getText());
txTextField.setText("");
}
}
}
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment