Skip to content

Commit

Permalink
Little less overhead when trace/debug logging is disabled (#1415)
Browse files Browse the repository at this point in the history
Signed-off-by: Jörg Sautter <[email protected]>
  • Loading branch information
joerg1985 authored Jan 20, 2024
1 parent 9f315fb commit 1356681
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ private int[] getPacket() throws IOException {

while (!closeHandler) {
int val = port.read();
logger.trace("ASH RX: {}", String.format("%02X", val));
if (logger.isTraceEnabled()) {
logger.trace("ASH RX: {}", String.format("%02X", val));
}
switch (val) {
case ASH_CANCEL_BYTE:
// Cancel Byte: Terminates a frame in progress. A Cancel Byte causes all data received since the
Expand Down Expand Up @@ -273,15 +275,17 @@ public void run() {
final AshFrame packet = AshFrame.createFromInput(packetData);
AshFrame responseFrame = null;
if (packet == null) {
logger.debug("<-- RX ASH error: BAD PACKET {}", frameToString(packetData));
if (logger.isDebugEnabled()) {
logger.debug("<-- RX ASH error: BAD PACKET {}", frameToString(packetData));
}

// Send a NAK and set rejection condition
if (!rejectionCondition) {
rejectionCondition = true;
responseFrame = new AshFrameNak(ackNum);
}
} else {
logger.debug("<-- RX ASH frame: {}", packet.toString());
logger.debug("<-- RX ASH frame: {}", packet);

// Reset the exception counter
exceptionCnt = 0;
Expand Down

0 comments on commit 1356681

Please sign in to comment.