about uart receive data

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

about uart receive data

519 Views
kevinli
Contributor II

Hi,all:

    cpu: imx6D

    board: sabresd like custom

    linux: rel_imx_4.14.98_2.3.0 and rel_imx_5.4.70_2.3.7

    test UART recvice data: nonblock mode, baud:921200bps, two line:rxd and txd. 

    slave will send out 3928 bytes data everytime

    problem: 4.14.98 can receive all 3928 bytes data every one read.

    but, 5.4.70_2.3.7 can't, may be read two or three times to finish all data, log like below

    so, that is why?

4.14 log:

DEBUG 2022-07-26 20:23:41.123 3928 receive: 3928 offset: 0
DEBUG 2022-07-26 20:23:41.123 0 receive: 0 offset: 3928
DEBUG 2022-07-26 20:23:41.128 rsp 0x38
DEBUG 2022-07-26 20:23:41.285 3928 receive: 3928 offset: 0
DEBUG 2022-07-26 20:23:41.285 0 receive: 0 offset: 3928
DEBUG 2022-07-26 20:23:41.290 rsp 0x38

5.4 log:

                                                       2048 receive: 2048 offset: 0
DEBUG 2022-07-27 09:31:23.139 0 receive: 0 offset: 2048
DEBUG 2022-07-27 09:31:23.151 frame :exlen=3928 but 2048
DEBUG 2022-07-27 09:31:23.158 1024 receive: 1024 offset: 2048
DEBUG 2022-07-27 09:31:23.158 0 receive: 0 offset: 3072
DEBUG 2022-07-27 09:31:23.164 frame :exlen=3928 but 3072
DEBUG 2022-07-27 09:31:23.170 856 receive: 856 offset: 3072
DEBUG 2022-07-27 09:31:23.170 0 receive: 0 offset: 3928
DEBUG 2022-07-27 09:31:23.178 rsp 0x38
DEBUG 2022-07-27 09:31:23.325 2048 receive: 2048 offset: 0
DEBUG 2022-07-27 09:31:23.325 0 receive: 0 offset: 2048
DEBUG 2022-07-27 09:31:23.333 frame :exlen=3928 but 2048
DEBUG 2022-07-27 09:31:23.341 1024 receive: 1024 offset: 2048
DEBUG 2022-07-27 09:31:23.341 0 receive: 0 offset: 3072
DEBUG 2022-07-27 09:31:23.347 frame :exlen=3928 but 3072
DEBUG 2022-07-27 09:31:23.354 856 receive: 856 offset: 3072
DEBUG 2022-07-27 09:31:23.354 0 receive: 0 offset: 3928
DEBUG 2022-07-27 09:31:23.362 rsp 0x38

    code:

if (SP_OK == sp_wait(event_set, 0)) {
    do {
    // kernel 5.10 can only read out 2048 bytes max
    gint new_arrived = sp_input_waiting(port);
    bytes_waiting = sp_nonblocking_read(port, &poll_buf[offset], new_arrived);
    zlog_debug(zl, "%d receive: %d offset: %d", new_arrived, bytes_waiting, offset);
    if (bytes_waiting > 0) {
        offset += bytes_waiting;
    }
    } while (bytes_waiting > 0);
}

...

0 Kudos
Reply
0 Replies