Skip to content

Commit 03f35e6

Browse files
JZimnolDhruvaG2000
authored andcommitted
Wire: fix the behavior of the arduino::ZephyrI2C::peek()
Added a negative return value to peek() in case there's no data to read. Signed-off-by: Jakub Zimnol <zimnol.jakub@gmail.com>
1 parent 9e134ee commit 03f35e6

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

libraries/Wire/Wire.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ int arduino::ZephyrI2C::available() { // TODO for ADS1115
9898

9999
int arduino::ZephyrI2C::peek() {
100100
uint8_t buf[1];
101-
int bytes_read = ring_buf_peek(&rxRingBuffer.rb, buf, 1);
102-
if (bytes_read == 0){
103-
return 0;
104-
}
101+
if (!ring_buf_peek(&rxRingBuffer.rb, buf, 1)){
102+
// No data available
103+
return -1;
104+
}
105105
return (int)buf[0];
106106
}
107107

0 commit comments

Comments
 (0)