Improve logging

aprs
sh123 2022-08-14 19:52:42 +03:00
rodzic 42b306d21c
commit 60c62a2f82
7 zmienionych plików z 36 dodań i 9 usunięć

Wyświetl plik

@ -149,7 +149,8 @@ public class Freedv implements Protocol {
long cntRead = Codec2.freedvRawDataRx(_freedvData, _dataBuffer, samplesData);
if (cntRead > 0) {
Log.i(TAG, "receive " + cntRead);
//_parentProtocolCallback.onReceiveCompressedAudio(null, null, -1, _dataBuffer);
// TODO, refactor, use onReceiveData
_parentProtocolCallback.onReceiveCompressedAudio(null, null, -1, _dataBuffer);
isRead = true;
}
ninData = Codec2.freedvNin(_freedvData);
@ -165,8 +166,7 @@ public class Freedv implements Protocol {
@Override
public void flush() throws IOException {
Log.i(TAG, "flush()");
// TODO buffers
// TODO, check if need to flush buffers
}
@Override

Wyświetl plik

@ -110,7 +110,7 @@ public class Hdlc implements Protocol {
//Log.i(TAG, "checksum: " + calculatedCrc + " " + packetCrc);
if (calculatedCrc == packetCrc) {
//Log.v(TAG, DebugTools.byteBitsToString(packetBits));
Log.i(TAG, "RX: " + DebugTools.bytesToHex(packetBytes));
//Log.i(TAG, "RX: " + DebugTools.bytesToHex(packetBytes));
_parentProtocolCallback.onReceiveCompressedAudio(null, null, -1, contentBytes);
}
}

Wyświetl plik

@ -296,6 +296,7 @@ public class Kiss implements Protocol {
case KISS_FEND:
if (_kissDataType == DataType.RAW) {
// NOTE, KISS does not distinguish between audio and data packets, upper layer should decide
// TODO, refactor, use onReceiveData
protocolCallback.onReceiveCompressedAudio(null, null, -1, Arrays.copyOf(_frameOutputBuffer, _frameOutputBufferPos));
} else if (_kissDataType == DataType.SIGNAL_REPORT && _isExtendedMode) {
byte[] signalLevelRaw = Arrays.copyOf(_kissCmdBuffer, _kissCmdBufferPos);

Wyświetl plik

@ -164,7 +164,7 @@ public class AprsDataPositionReport implements AprsData {
if (longitude == null) return false;
_position.longitude = getUncompressedCoordinate(longitude.getBytes(), false);
if (comment != null)
_position.comment = comment;
_position.comment = TextTools.stripNulls(comment);
_position.hasSpeed = false;
_position.hasBearing = false;
@ -283,7 +283,7 @@ public class AprsDataPositionReport implements AprsData {
_position.hasAltitude = false;
}
// read comment until the end
_position.comment = strTail;
_position.comment = TextTools.stripNulls(strTail);
return true;
}

Wyświetl plik

@ -3,6 +3,7 @@ package com.radio.codec2talkie.protocol.aprs;
import com.radio.codec2talkie.protocol.aprs.tools.AprsTools;
import com.radio.codec2talkie.protocol.message.TextMessage;
import com.radio.codec2talkie.protocol.position.Position;
import com.radio.codec2talkie.tools.TextTools;
import com.radio.codec2talkie.tools.UnitTools;
import java.nio.ByteBuffer;
@ -220,9 +221,9 @@ public class AprsDataPositionReportMicE implements AprsData {
if (infoData.length > 11 && infoData[11] == '}') {
_position.hasAltitude = true;
_position.altitudeMeters = ((infoData[8] - 33) * 91 * 91 + (infoData[9] - 33) * 91 + (infoData[10] - 33)) - 10000;
_position.comment = new String(Arrays.copyOfRange(infoData, 12, infoData.length));
_position.comment = TextTools.stripNulls(new String(Arrays.copyOfRange(infoData, 12, infoData.length)));
} else {
_position.comment = new String(Arrays.copyOfRange(infoData, 8, infoData.length));
_position.comment = TextTools.stripNulls(new String(Arrays.copyOfRange(infoData, 8, infoData.length)));
}
_position.maidenHead = UnitTools.decimalToMaidenhead(_position.latitude, _position.longitude);

Wyświetl plik

@ -3,6 +3,7 @@ package com.radio.codec2talkie.protocol.ax25;
import androidx.annotation.NonNull;
import com.radio.codec2talkie.tools.DebugTools;
import com.radio.codec2talkie.tools.TextTools;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
@ -157,7 +158,11 @@ public class AX25Packet {
String path = digipath == null ? "" : digipath;
if (!path.isEmpty())
path = "," + path;
return String.format("%s>%s%s:%s", src, dst, path, DebugTools.bytesToDebugString(rawData));
String info = DebugTools.bytesToDebugString(rawData);
if (!isAudio) {
info = DebugTools.bytesToDebugString(TextTools.stripNulls(rawData));
}
return String.format("%s>%s%s:%s", src, dst, path, info);
}
private boolean digiRepeatMicE() {

Wyświetl plik

@ -1,5 +1,9 @@
package com.radio.codec2talkie.tools;
import android.util.Log;
import java.util.Arrays;
public class TextTools {
public static String addZeroWidthSpaces(String text) {
return text.replaceAll(".(?!$)", "$0\u200b");
@ -15,4 +19,20 @@ public class TextTools {
}
return count;
}
public static String stripNulls(String text) {
int pos = text.indexOf('\0');
if (pos == -1) return text;
return text.substring(0, pos);
}
public static byte[] stripNulls(byte[] data) {
int i = 0;
for (byte b : data) {
if (b == 0) break;
i++;
}
if (i == data.length) return data;
return Arrays.copyOf(data, i);
}
}