Skip to content

Commit adac7eb

Browse files
committed
fixup! feat(split): Add full-duplex wired split support
1 parent cb2fb5d commit adac7eb

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

Diff for: app/src/split/wired/peripheral.c

+14-9
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,27 @@ static void serial_cb(const struct device *dev, void *user_data) {
139139
#else
140140

141141
static void read_pending_rx(void) {
142-
uint8_t *buf;
143142
struct ring_buf *ring_buf = &chosen_rx_buf;
144-
uint32_t claim_len = ring_buf_put_claim(ring_buf, &buf, 1);
145-
143+
uint8_t *buf;
144+
uint32_t read = 0;
145+
uint32_t claim_len = ring_buf_put_claim(ring_buf, &buf, ring_buf_space_get(ring_buf));
146146
if (claim_len < 1) {
147147
LOG_WRN("No room available for reading in from the serial port");
148148
return;
149149
}
150150

151-
if (uart_poll_in(uart, buf) < 0) {
152-
ring_buf_put_finish(ring_buf, 0);
153-
} else {
154-
ring_buf_put_finish(ring_buf, 1);
155-
if (ring_buf_size_get(ring_buf) >= sizeof(struct command_envelope)) {
156-
k_work_submit(&publish_commands);
151+
while (read < claim_len) {
152+
if (uart_poll_in(uart, buf + read) < 0) {
153+
break;
157154
}
155+
156+
read++;
157+
}
158+
159+
ring_buf_put_finish(ring_buf, read);
160+
161+
if (ring_buf_size_get(ring_buf) >= sizeof(struct command_envelope)) {
162+
k_work_submit(&publish_commands);
158163
}
159164
}
160165

0 commit comments

Comments
 (0)