GetVoltage() unconditionally leaves I2C bus in EXTERNAL state — latent hazard
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 56/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- arduino, cpp
- Lĩnh vực
- embedded-iot
Hướng nghiên cứu
Start at the GetVoltage() entry point and trace I2CState(INTERNAL) / I2CState(EXTERNAL), then inspect its AddDataPoint() call sites and the possible GetOnBoardVals() context. Done means GetVoltage() no longer changes the caller's I2C bus state when invoked from an INTERNAL context, while current EXTERNAL usage remains safe.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Issue
GetVoltage() now wraps the ADC read with I2CState(INTERNAL) / I2CState(EXTERNAL) (added in 7c04bf1) without saving or restoring the caller's I2C bus state. The EXTERNAL restore at the end is unconditional.
float Okapi::GetVoltage(uint8_t Pin) {
I2CState(INTERNAL);
float Val = ADC_Ext.readADC_SingleEnded(Pin) * 0.1875;
I2CState(EXTERNAL); // always left on EXTERNAL, regardless of caller state
return Val;
}
Current status
All current call sites for GetVoltage() are in user Update() callbacks, which AddDataPoint() always invokes during the EXTERNAL phase — so the unconditional restore is safe for present usage.
Latent hazard
If GetVoltage() is ever called from setup() or any INTERNAL context (e.g., added to GetOnBoardVals() in the future), the bus will be left on EXTERNAL, corrupting subsequent BME280/RTC reads. There is nothing in the function signature or documentation to warn callers of this constraint.
Fix
Save and restore the caller's I2C state, or document the EXTERNAL-context-only precondition prominently.
Severity
Low (latent) — not triggered by current library code; risk increases as the API evolves.
🤖 Generated with Claude Code
- Ngôn ngữ chính
- C++
- Star
- 1
- Fork
- 0
- 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
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NorthernWidget/Okapi_Library
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Tất cả issue của NorthernWidget/Okapi_Library
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
FriendsofECCE/ECCE#336 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
bitcoin-core/gui-qml#1030 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
tesseract-robotics/tesseract#1384 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
NVIDIA/nccl-extensions#26 ·