Skip to content

Commit 3408734

Browse files
committed
Fix usb log buffer position writes.
1 parent bb59d27 commit 3408734

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

right/src/usb_log_buffer.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ static void addChar(char c) {
2727
buffer[POS(bufferLength)] = c;
2828
bufferLength++;
2929
} else {
30-
buffer[bufferPosition++] = c;
31-
bufferPosition %= USB_LOG_BUFFER_SIZE;
30+
buffer[bufferPosition] = c;
31+
bufferPosition = (bufferPosition + 1) % USB_LOG_BUFFER_SIZE;
3232
}
3333
}
3434
}
@@ -47,11 +47,9 @@ uint16_t UsbLogBuffer_Consume(uint8_t* outBuf, uint16_t outBufSize) {
4747
uint16_t copied = 0;
4848
uint16_t remaining = (bufferLength < outBufSize) ? bufferLength : outBufSize;
4949
while (remaining > 0) {
50-
char a = buffer[bufferPosition++];
50+
char a = buffer[bufferPosition];
51+
bufferPosition = (bufferPosition + 1) % USB_LOG_BUFFER_SIZE;
5152
outBuf[copied++] = a;
52-
if (bufferPosition >= USB_LOG_BUFFER_SIZE) {
53-
bufferPosition = 0;
54-
}
5553
remaining--;
5654
bufferLength--;
5755
}

0 commit comments

Comments
 (0)