kopia lustrzana https://github.com/felHR85/UsbSerial
changed protocol buffer
rodzic
d02adc6b08
commit
b5863e22cb
|
@ -53,7 +53,10 @@ public class ProtocolBuffer {
|
||||||
this.separator = delimiter;
|
this.separator = delimiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void appendData(byte[] data){
|
public synchronized void appendData(byte[] data){
|
||||||
|
// Ignore the frequent empty calls
|
||||||
|
if (data.length == 0) return;
|
||||||
|
|
||||||
if(mode.equals(TEXT)){
|
if(mode.equals(TEXT)){
|
||||||
try {
|
try {
|
||||||
String dataStr = new String(data, "UTF-8");
|
String dataStr = new String(data, "UTF-8");
|
||||||
|
@ -69,8 +72,7 @@ public class ProtocolBuffer {
|
||||||
index = stringBuffer.toString().indexOf(delimiter, prevIndex);
|
index = stringBuffer.toString().indexOf(delimiter, prevIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(prevIndex < buffer.length()
|
if( /*prevIndex < buffer.length() &&*/ prevIndex > 0){
|
||||||
&& prevIndex > 0){
|
|
||||||
String tempStr = buffer.substring(prevIndex, buffer.length());
|
String tempStr = buffer.substring(prevIndex, buffer.length());
|
||||||
stringBuffer.setLength(0);
|
stringBuffer.setLength(0);
|
||||||
stringBuffer.append(tempStr);
|
stringBuffer.append(tempStr);
|
||||||
|
|
Ładowanie…
Reference in New Issue