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

GetVoltage() unconditionally leaves I2C bus in EXTERNAL state — latent hazard

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

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

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 NorthernWidget/Okapi_Library

Tất cả issue của NorthernWidget/Okapi_Library

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.