Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

USB and COM port share one command buffer

Đang mở
#615 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

@Yukti007 đang làm issue này rồi.

Từ ngày 13/10/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

High Priority

Describe the bug
The Krake reads text commands from two ports: the USB serial port and the RS-232 COM port. Both ports put their characters into the same command buffer, with the same character counter. If one port has sent part of a command but not the end-of-line yet, characters from the other port get added to the end of it. The Krake then runs one wrong command made from pieces of both.

Short Summary of the expected behavior:
Each port's commands are handled separately. A command from one port is never mixed with characters from the other port.

Short Summary of the buggy behavior:
A half-finished line from one port gets finished by characters from the other port. This can give the wrong alarm level, the wrong message text, or a lost alarm.

To Reproduce
Found by reading the code. Not yet tested on a real Krake board. Suggested steps to confirm:

  1. Connect a Krake to a PC by USB and open a serial monitor at 115200 baud, with line ending set to "No line ending".
  2. Connect a second serial terminal to the COM port (DB9, RS-232).
  3. On USB, type a2Pump and send it (no newline is sent).
  4. On the COM port, send a5Fire with a newline.
  5. See error: the Krake shows a level 2 alarm with the text "Pumpa5Fire" instead of a level 5 alarm with the text "Fire".

Expected behavior
The COM port command a5Fire should give a level 5 alarm with the text "Fire". The unfinished text on USB should stay with the USB port and not affect the COM port.

Screenshots
None. Not yet tested on hardware.

Hardware description
Model: Krake (GPAD_API firmware), checked against main at commit b6ea4b3 (2026-09-20)
Serial Number: N/A (found by reading the code)
Other: Affects any Krake with both the USB serial and the COM port connected.

Test Equipment
Model: N/A (not yet tested)
Serial Number: N/A

Additional context
Where in the code:

Why it happens: processSerial() keeps a half-finished line in the buffer between calls, but there is only one buffer and one counter for both ports. Nothing records which port the half-finished line came from. It is not two tasks running at once: everything runs in loop(), one call after the other.

Side effect: if one port sends a line that is too long, the buffer is cleared. That also throws away the other port's half-finished command and cancels pending alarm audio (gpad_serial.cpp lines 107–113).

How likely: low to medium. Most setups use one port at a time, but it is easy to hit while debugging with a serial monitor open.

Possible fix: give each port its own buffer and its own character counter, passed into processSerial(). The comment at gpad_serial.cpp lines 45–46 already suggests making the buffer a parameter.

Related: #283 (shared global variables).

Ngôn ngữ chính
C++
Star
9
Fork
6
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PubInv/krake

Tất cả issue của PubInv/krake

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.