Skip to content

Commit d65005b

Browse files
silabs-bozontDhruvaG2000
authored andcommitted
core: serial: fix availableForWrite()
availableForWrite() was taking the free space of the Rx buffer instead of the Tx buffer.
1 parent 494ba17 commit d65005b

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

cores/arduino/zephyrSerial.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ int arduino::ZephyrSerial::available() {
116116
return ret;
117117
}
118118

119+
int arduino::ZephyrSerial::availableForWrite() {
120+
int ret;
121+
122+
k_sem_take(&tx.sem, K_FOREVER);
123+
ret = ring_buf_space_get(&tx.ringbuf);
124+
k_sem_give(&tx.sem);
125+
126+
return ret;
127+
}
128+
119129
int arduino::ZephyrSerial::peek() {
120130
uint8_t data;
121131

0 commit comments

Comments
 (0)