Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cores/portduino/linux/LinuxHardwareI2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ namespace arduino {
void LinuxHardwareI2C::begin(const char * device) {
if (!hasBegun) {
i2c_file = open(device, O_RDWR);
hasBegun = true;
if (i2c_file >= 0)
hasBegun = true;
}
}
void LinuxHardwareI2C::end() {
if (hasBegun) {
close(i2c_file);
i2c_file = -1;
hasBegun = false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion cores/portduino/linux/LinuxHardwareI2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ enum ResultI2c {
};

class LinuxHardwareI2C : public HardwareI2C {
int i2c_file = 0;
int i2c_file = -1; // unopened: fail fast instead of operating on stdin/stdout

public:
void begin(const char* device);
Expand Down