File tree 1 file changed +14
-9
lines changed
1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -139,22 +139,27 @@ static void serial_cb(const struct device *dev, void *user_data) {
139
139
#else
140
140
141
141
static void read_pending_rx (void ) {
142
- uint8_t * buf ;
143
142
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 ));
146
146
if (claim_len < 1 ) {
147
147
LOG_WRN ("No room available for reading in from the serial port" );
148
148
return ;
149
149
}
150
150
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 ;
157
154
}
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 );
158
163
}
159
164
}
160
165
You can’t perform that action at this time.
0 commit comments