modem: ubx: fix incoming byte processing

`ret` holds the amount of bytes received from the modem. However during
processing of the bytes its value is overwritten by the return value of
`modem_ubx_process_received_byte`, in practice discarding all but the
first byte read.

To prevent this, store the length in a separate variable.

Signed-off-by: Anders T. Akre <anders@akre.io>
This commit is contained in:
Anders T. Akre 2024-07-16 10:31:00 +02:00 committed by Anas Nashif
parent 93c9da6694
commit 26cd98e483

View file

@ -269,7 +269,9 @@ static void modem_ubx_process_handler(struct k_work *item)
return;
}
for (int i = 0; i < ret; i++) {
const size_t length = ret;
for (int i = 0; i < length; i++) {
ret = modem_ubx_process_received_byte(ubx, ubx->receive_buf[i]);
if (ret == 0) { /* Frame matched successfully. Terminate the script. */
break;